Skip to content

Fix "new trace_macros doesn't work if there's an error during expansion" - #44088

Merged
bors merged 6 commits into
rust-lang:masterfrom
bjorn3:better_trace_macros
Sep 17, 2017
Merged

Fix "new trace_macros doesn't work if there's an error during expansion"#44088
bors merged 6 commits into
rust-lang:masterfrom
bjorn3:better_trace_macros

Conversation

@bjorn3

Copy link
Copy Markdown
Member

Fixes#43493

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@bjorn3

Copy link
Copy Markdown
MemberAuthor

r? @jseyfried

@durka

Copy link
Copy Markdown
Contributor

Let's work up a test?

@bjorn3

Copy link
Copy Markdown
MemberAuthor

Will do it tommorrow when I have more time to build rust

@shepmastershepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 25, 2017
ProcMacroDerive(..) | BuiltinDerive(..) => {
self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path));
self.cx.trace_macros_diag();
kind.dummy(attr.span)

Copy link
Copy Markdown
Contributor

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.

@shepmaster

Copy link
Copy Markdown
Member

@bjorn3 A gentle reminder - it's been 7 days since your last message!

@bjorn3

Copy link
Copy Markdown
MemberAuthor

@shepmaster Working on it.

@bjorn3bjorn3 changed the title Fix "new trace_macros doesn't work if there's an error during expansion"[WIP] Fix "new trace_macros doesn't work if there's an error during expansion"Sep 2, 2017
@bjorn3

Copy link
Copy Markdown
MemberAuthor

@jseyfried: Should be working.

Travis job #58449.5 failed: The command "eval git fetch origin +refs/pull/44088/merge: " failed 3 times.

@jseyfriedjseyfried changed the title [WIP] Fix "new trace_macros doesn't work if there's an error during expansion"Fix "new trace_macros doesn't work if there's an error during expansion"Sep 5, 2017

@jseyfriedjseyfried left a comment

Copy link
Copy Markdown
Contributor

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();.

db.emit();
}
// Fixme: does this result in errors?
self.expansions.clear();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Copy Markdown
MemberAuthor

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

_ => {
let msg = &format!("macro `{}` may not be used in attributes", attr.path);
self.cx.span_err(attr.span, msg);
self.cx.trace_macros_diag();

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

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.

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();

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

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)

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@aidanhsaidanhs added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2017
@bjorn3

Copy link
Copy Markdown
MemberAuthor

ping @jseyfried

@jseyfried

Copy link
Copy Markdown
Contributor

@bjorn3 Ok, makes sense.
@bors r+

@bors

bors commented Sep 17, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 0a2c95b has been approved by jseyfried

TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…ried
Fix "new trace_macros doesn't work if there's an error during expansion"
Fixesrust-lang#43493
@TimNNTimNN mentioned this pull request Sep 17, 2017
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…ried
Fix "new trace_macros doesn't work if there's an error during expansion"
Fixesrust-lang#43493
@TimNNTimNN mentioned this pull request Sep 17, 2017
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…ried
Fix "new trace_macros doesn't work if there's an error during expansion"
Fixesrust-lang#43493
@TimNNTimNN mentioned this pull request Sep 17, 2017
bors added a commit that referenced this pull request Sep 17, 2017
@bors
bors merged commit 0a2c95b into rust-lang:masterSep 17, 2017
@bors

bors commented Sep 17, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 0a2c95b with merge 1cdd689...

@bjorn3
bjorn3 deleted the better_trace_macros branch September 18, 2017 06:09
@kennytm

Copy link
Copy Markdown
Member

@bors p=-1 retry

Why are you still appearing in the queue

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@bjorn3@rust-highfive@durka@shepmaster@jseyfried@bors@kennytm@nikomatsakis@aidanhs