-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Adjust spans into the for loops context before creating the new desugaring spans.
#148465
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
… and `into_iter` call spans.
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
| let head_span = | ||
| head.span.find_ancestor_in_same_ctxt(e.span).unwrap_or(head.span).with_ctxt(for_ctxt); |
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 currently failing tests/ui/suggest-dereferences/invalid-suggest-deref-issue127590 can be fixed by making a second mark rather than reusing for_ctxt. I'm not exactly clear why this matters since the only change this makes is using two identical, but separate SyntaxContexts.
Ideally only a single SyntaxContext would be created since there's only one for loop.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
When lowering
forloops, the spans for theinto_itercall and theSomepattern used the span of the provided pattern and head expression. If either of those came from a differentSyntaxContextthis would result in some very strange contexts. e.g.:This would result in the
into_itercall have a context chain ofdesugar => m!() => rootwhich is completely nonsensical;m!()does not have aforloop. Theinto_itercall also ends up located at{ $e }rather than inside thefor _ in _part.This fixes that by walking the spans up to the
forloop's context first. This will not handle adjusting the location of macro variable expansions (e.g.for _ in $e), but this does adjust the context to match theforloops.This ended up causing rust-lang/rust-clippy#16008. Clippy should be using a
debug_assertrather thanunreachable, but it still results in a bug either way.