-
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
When recovering from a :
in a pattern, use adequate AST pattern
#87160
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
ping |
r? @nagisa |
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 think extracting the code to "join" two patterns into a function might make the code cleaner.
} | ||
PatKind::Path(old_qself, old_path) => { | ||
for segment in old_path.segments.iter().rev() { | ||
path.segments.insert(0, segment.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.
old_path.segments.extend(path.segments)
or something of the sort would be nicer, perhaps?
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.
What do you think of this?
path.segments = old_path
.segments
.iter()
.cloned()
.chain(take(&mut path.segments))
.collect();
This comment has been minimized.
This comment has been minimized.
e185cba
to
5743c56
Compare
☔ The latest upstream changes (presumably #85346) made this pull request unmergeable. Please resolve the merge conflicts. |
0ae2f80
to
03a57e0
Compare
span, | ||
"maybe write a path separator here", | ||
"::".to_string(), | ||
Applicability::MachineApplicable, |
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.
Is this truly MachineApplicable
? We don't really check with the resolver here that the constructed pattern will match, do we?
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.
Seems good, except for machine applicability stuff.
03a57e0
to
c027105
Compare
@bors r=nagisa |
📌 Commit c027105 has been approved by |
When recovering from a `:` in a pattern, use adequate AST pattern If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
When recovering from a `:` in a pattern, use adequate AST pattern If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
When recovering from a `:` in a pattern, use adequate AST pattern If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#87160 (When recovering from a `:` in a pattern, use adequate AST pattern) - rust-lang#90985 (Use `get_diagnostic_name` more) - rust-lang#91087 (Remove all migrate.nll.stderr files) - rust-lang#91207 (Add support for LLVM coverage mapping format versions 5 and 6) - rust-lang#91298 (Improve error message for `E0659` if the source is not available) - rust-lang#91346 (Add `Option::inspect` and `Result::{inspect, inspect_err}`) - rust-lang#91404 (Fix bad `NodeId` limit checking.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
If the suggestion to use
::
instead of:
in the pattern isn't correct, a second resolution error will be emitted.