Skip to content

Conversation

notriddle
Copy link
Contributor

Fixes #121632

@rustbot
Copy link
Collaborator

rustbot commented Sep 27, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 27, 2024
@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle force-pushed the notriddle/suggest-wrap-parens-fn-pointer branch from 5367e7c to c48b0d4 Compare September 27, 2024 01:20
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Sep 27, 2024
@compiler-errors
Copy link
Member

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
Copy link
Collaborator

bors commented Sep 27, 2024

📌 Commit c48b0d4 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 27, 2024
@BoxyUwU BoxyUwU assigned compiler-errors and unassigned BoxyUwU 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![
Copy link
Member

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?

Copy link
Contributor Author

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.

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
@bors bors merged commit 6b0c897 into rust-lang:master Sep 27, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 27, 2024
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
@notriddle notriddle deleted the notriddle/suggest-wrap-parens-fn-pointer branch September 27, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Named functions do not implement traits implemented on fn()
7 participants