-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "new trace_macros doesn't work if there's an error during expansion" #44088
Conversation
…r during expansion)
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @jseyfried |
Let's work up a test? |
Will do it tommorrow when I have more time to build rust |
@@ -439,11 +440,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> { | |||
} | |||
ProcMacroDerive(..) | BuiltinDerive(..) => { | |||
self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path)); | |||
self.cx.trace_macros_diag(); | |||
kind.dummy(attr.span) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need self.cx.trace_macros_diag();
when we're not panicking immediately after.
@bjorn3 A gentle reminder - it's been 7 days since your last message! |
@shepmaster Working on it. |
@jseyfried: Should be working. Travis job #58449.5 failed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than what appears to be excessive self.cx.trace_macros_diag();
.
for (sp, notes) in self.expansions.iter() { | ||
let mut db = self.parse_sess.span_diagnostic.span_note_diag(*sp, "trace_macro"); | ||
for note in notes { | ||
db.note(note); | ||
} | ||
db.emit(); | ||
} | ||
// Fixme: does this result in errors? | ||
self.expansions.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this prevent reporting an expansion trace twice or more
kind.dummy(attr.span) | ||
} | ||
_ => { | ||
let msg = &format!("macro `{}` may not be used in attributes", attr.path); | ||
self.cx.span_err(attr.span, msg); | ||
self.cx.trace_macros_diag(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this here? This error shouldn't abort expansion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of the trace notes is unstable otherwise.
@@ -482,6 +485,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { | |||
if let Err(msg) = validate_and_set_expn_info(def_span.map(|(_, s)| s), | |||
false, false) { | |||
self.cx.span_err(path.span, &msg); | |||
self.cx.trace_macros_diag(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this, and the most of the others in this file.
We use dummy expansions (kind.dummy(span)
) so that we don't have to abort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
cx.span_fatal(best_fail_spot.substitute_dummy(sp), &best_fail_msg); | ||
cx.span_err(best_fail_spot.substitute_dummy(sp), &best_fail_msg); | ||
cx.trace_macros_diag(); | ||
DummyResult::any(sp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With DummyResult
we shouldn't need cx.trace_macros_diag();
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
ping @jseyfried |
📌 Commit 0a2c95b has been approved by |
…ried Fix "new trace_macros doesn't work if there's an error during expansion" Fixes rust-lang#43493
…ried Fix "new trace_macros doesn't work if there's an error during expansion" Fixes rust-lang#43493
…ried Fix "new trace_macros doesn't work if there's an error during expansion" Fixes rust-lang#43493
@bors p=-1 retry Why are you still appearing in the queue |
Fixes #43493