diagnostics: wrap fn cast suggestions in parens when needed#130911
Merged
bors merged 1 commit intorust-lang:masterfrom Sep 27, 2024
Merged
diagnostics: wrap fn cast suggestions in parens when needed#130911bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
This comment has been minimized.
This comment has been minimized.
5367e7c to
c48b0d4
Compare
compiler-errors
approved these changes
Sep 27, 2024
Contributor
|
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 |
Collaborator
chenyukang
reviewed
Sep 27, 2024
| 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![ |
Member
There was a problem hiding this comment.
span_look_ahead is not correct sometimes, can we use the expr way to find out there is a method call?
Contributor
Author
There was a problem hiding this comment.
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.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 27, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Sep 27, 2024
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #121632