Uh oh!
There was an error while loading. Please reload this page.
diagnostics: wrap fn cast suggestions in parens when needed - #130911
Merged
bors merged 1 commit intoSep 27, 2024
Conversation
rustbot
commented
Sep 27, 2024
Collaborator
This comment has been minimized.
This comment has been minimized.
notriddleforce-pushed
the
notriddle/suggest-wrap-parens-fn-pointer
branch
from
September 27, 2024 01:20
5367e7c to
c48b0d4Comparecompiler-errors
approved these changes
Sep 27, 2024
compiler-errors
commented
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 |
bors
commented
Sep 27, 2024
Collaborator
| 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?
ContributorAuthor
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 Fixesrust-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 freeto 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