-
Notifications
You must be signed in to change notification settings - Fork 13k
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 suggestion to borrow in struct #71829
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
); | ||
|
||
// This if is to prevent a special edge-case | ||
if !has_colon || has_double_colon || has_bracket { |
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 would prefer this to check for !span.from_expansion()
than using snippets.
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.
uhhh thanks. That's much better :)
@bors r+ rollup |
📌 Commit e776121 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#71829 (Fix suggestion to borrow in struct) - rust-lang#72123 (Stabilize process_set_argv0 feature for Unix) - rust-lang#72235 (Clean up E0590 explanation) - rust-lang#72345 (Clean up E0593 explanation) - rust-lang#72376 ([self-profling] Record the cgu name when doing codegen for a module) - rust-lang#72399 (Add fast-path optimization for Ipv4Addr::fmt) - rust-lang#72435 (rustllvm: Fix warnings about unused function parameters) Failed merges: r? @ghost
The corresponding issue is #71136.
The compiler suggests that borrowing
the_foos
might solve the problem. This is obviously incorrect.I propose as fix to check if there is any colon in the span. However, there might a case where
my_method(B { a: 1, b : foo })
would be appropriate to show a suggestion for&B ...
. To fix that too, we can simply check if there is a bracket in the span. This is only possible because both spans are different.Issue's span:
the_foos: Vec<Foo>
other's span:
B { a : 1, b : foo }