-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Omit suggestions when spans are invalid #147849
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
base: master
Are you sure you want to change the base?
Conversation
related MCP: rust-lang/compiler-team#929 |
|
||
#[proc_macro_attribute] | ||
pub fn all_spans_same(_: TokenStream, ts: TokenStream) -> TokenStream { | ||
spans_callsite(ts) |
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.
recursively set all spans in the output to the callsite
This comment has been minimized.
This comment has been minimized.
|
||
#[all_spans_same::all_spans_same] | ||
//~^ ERROR wrong meta list delimiters | ||
#[allow{}] |
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.
crashes, because we suggest changing {} to () but the suggestion consists of two parts (
and )
with both the same span
b876dd7
to
7d26571
Compare
.substitutions | ||
.iter() | ||
.filter_map(|substitution| { | ||
let mut parts = substitution.parts.clone(); |
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.
skip outputting suggestions with overlapping spans to JSON, same check as in lib.rs
// handed approach to avoid ICEs by ignoring the suggestion outright. | ||
let invalid = subst.parts.iter().any(|item| sm.is_valid_span(item.span).is_err()); | ||
if invalid { | ||
num_omitted.update(|i| i + 1); |
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.
some suggestions were already silently dropped, change this to count them
if substitution | ||
.parts | ||
.array_windows() | ||
.find(|[a, b]| a.span.overlaps(b.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.
instead of failing an assertion, count how many times this happens and show this to the user
The job Click to see the possible cause of the failure (guessed by this bot)
|
r? @ghost
introduces a new compiletest directive:
//@ rustfix-dont-test-fixed
which is needed because I want to run rustfix, making sure rustfix doesn't crash, but then I don't expect the fixed code to compile since the suggestion was omitted and nothing was fixed.