Merge remote-tracking branch 'upstream/master' into pr/Demonthos/473

This commit is contained in:
Demonthos committed 2022-07-02 18:48:32 -05:00
commit 55e262b2c6
64 files changed
+1119 -761

No files matched your search

@@ -113,9 +113,9 @@ impl ToTokens for CapturedContextBuilder {
let expr = segment.to_token_stream();
let as_string = expr.to_string();
let format_expr = if format_args.is_empty() {
"{".to_string() + format_args + "}"
"{".to_string() + &format_args + "}"
} else {
"{".to_string() + ":" + format_args + "}"
"{".to_string() + ":" + &format_args + "}"
};
Some(quote! {
FormattedArg{
+17
View File
@@ -1,3 +1,5 @@
use std::fmt::Display;
use serde::{Deserialize, Serialize};
use crate::CodeLocation;
@@ -37,3 +39,18 @@ impl ParseError {
ParseError { message, location }
}
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::ParseError(error) => write!(
f,
"parse error:\n--> at {}:{}:{}\n\t{:?}\n",
error.location.file_path, error.location.line, error.location.column, error.message
),
Error::RecompileRequiredError(reason) => {
write!(f, "recompile required: {:?}\n", reason)
}
}
}
}
+12 -4
View File
@@ -39,7 +39,7 @@ fn resolve_ifmt(ifmt: &IfmtInput, captured: &IfmtArgs) -> Result<String, Error>
}
}
}
Segment::Literal(lit) => result.push_str(lit),
Segment::Literal(lit) => result.push_str(&lit),
}
}
Ok(result)
@@ -126,12 +126,12 @@ fn build_node<'a>(
ElementAttr::AttrExpression { .. }
| ElementAttr::CustomAttrExpression { .. } => {
let (name, value) = match &attr.attr {
let (name, value, span) = match &attr.attr {
ElementAttr::AttrExpression { name, value } => {
(name.to_string(), value)
(name.to_string(), value, name.span())
}
ElementAttr::CustomAttrExpression { name, value } => {
(name.value(), value)
(name.value(), value, name.span())
}
_ => unreachable!(),
};
@@ -151,6 +151,14 @@ fn build_node<'a>(
is_volatile: false,
namespace,
});
} else {
return Err(Error::ParseError(ParseError::new(
syn::Error::new(
span,
format!("unknown attribute: {}", name),
),
ctx.location.clone(),
)));
}
} else {
return Err(Error::RecompileRequiredError(
+2
View File
@@ -150,6 +150,8 @@ impl RsxContext {
fn report_error(&self, error: Error) {
if let Some(handler) = &self.data.write().unwrap().error_handler {
handler.handle_error(error)
} else {
panic!("no error handler set for this platform...\n{}", error);
}
}