-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
diagnostics: wrap fn cast suggestions in parens when needed #130911
diagnostics: wrap fn cast suggestions in parens when needed #130911
Conversation
This comment has been minimized.
This comment has been minimized.
5367e7c
to
c48b0d4
Compare
I'm not too happy with how span-based this approach is. I think this is generally a shortcoming of trait selection errors, given the way that we fail to track much of the necessary "source" information. But I guess it's not significantly worse than existing diagnostics code. @bors r+ rollup |
span.shrink_to_hi(), | ||
// Wrap method receivers and `&`-references in parens | ||
let suggestion = if self.tcx.sess.source_map().span_look_ahead(span, ".", Some(50)).is_some() { | ||
vec![ |
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.
span_look_ahead
is not correct sometimes, can we use the expr
way to find out there is a method call?
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 originally tried to do that, but couldn't get a expr of the actual method call. When I tried using FindExprBySpan
, it returned None.
…kingjubilee Rollup of 8 pull requests Successful merges: - rust-lang#130313 ([`cfg_match`] Generalize inputs) - rust-lang#130706 ([rustdoc] Remove unneeded jinja comments) - rust-lang#130846 (Revert Break into the debugger on panic (129019)) - rust-lang#130875 (update `compiler-builtins` to 0.1.126) - rust-lang#130889 (Weekly `cargo update`: only `rustbook`) - rust-lang#130892 (Partially update `library/Cargo.lock`) - rust-lang#130911 (diagnostics: wrap fn cast suggestions in parens when needed) - rust-lang#130912 (On implicit `Sized` bound on fn argument, point at type instead of pattern) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#130911 - notriddle:notriddle/suggest-wrap-parens-fn-pointer, r=compiler-errors diagnostics: wrap fn cast suggestions in parens when needed Fixes rust-lang#121632
Fixes #121632