Point at type ascription before macro invocation on expansion parse error

This commit is contained in:
Esteban Küber
2019-07-18 18:36:19 -07:00
parent 04b88a9eba
commit c82e1f2d0e
9 changed files with 57 additions and 13 deletions

View File

@@ -517,8 +517,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
result
}
SyntaxExtensionKind::LegacyBang(expander) => {
let prev = self.cx.current_expansion.prior_type_ascription;
self.cx.current_expansion.prior_type_ascription =
mac.node.prior_type_ascription;
let tok_result = expander.expand(self.cx, span, mac.node.stream());
if let Some(result) = fragment_kind.make_from(tok_result) {
let result = if let Some(result) = fragment_kind.make_from(tok_result) {
result
} else {
let msg = format!("non-{kind} macro in {kind} position: {path}",
@@ -526,7 +529,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
self.cx.span_err(span, &msg);
self.cx.trace_macros_diag();
fragment_kind.dummy(span)
}
};
self.cx.current_expansion.prior_type_ascription = prev;
result
}
_ => unreachable!()
}