Skip to content

Conversation

@Kivooeo
Copy link
Member

@Kivooeo Kivooeo commented Sep 7, 2025

Currently the suggestion for this code

fn main() {}

struct A {
    field: i32,
}

impl A {
    fn f(&&self) {}
}

looks like this, which is incorrect and missleading

   Compiling playground v0.0.1 (/playground)
error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
 --> src/main.rs:8:16
  |
8 |     fn f(&&self) {}
  |                ^ expected one of 9 possible tokens
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: explicitly ignore the parameter name
  |
8 |     fn f(_: &&self) {}
  |          ++

So this fixes it and make more correct suggestions

error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
 --> /home/gh-Kivooeo/test_/src/main.rs:8:16
  |
8 |     fn f(&&self) {}
  |                ^ expected one of 9 possible tokens
  |
help: `self` should be `self`, `&self` or `&mut self`, please remove extra references
  |
8 -     fn f(&&self) {}
8 +     fn f(&self) {}

Implementation is pretty self-documenting, but if you have suggestions on how to improve this (according to current test, which may be not fully covering all cases, this is works very well) or have some funny edge cases to show, I would appreciate it

r? compiler

@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 7, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the a-lot-of-references-in-self branch from ac5c2a2 to efd1bd0 Compare September 7, 2025 18:39
@petrochenkov
Copy link
Contributor

I'm not sure if it's useful to give a special suggestion for this.
I guess &&self specifically is possible in practice as a typo, but anything more than that, especially intentionally? Very unlikely.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2025
@rust-cloud-vms rust-cloud-vms bot force-pushed the a-lot-of-references-in-self branch from efd1bd0 to cd574ab Compare September 25, 2025 18:49
@Kivooeo
Copy link
Member Author

Kivooeo commented Sep 25, 2025

Let's try this one, I removed second suggestion with self: Self

Not sure what to do with cases where there is more than two references, but I'd keep it as it just because current suggestion is even worse and not correct in any way

@Kivooeo
Copy link
Member Author

Kivooeo commented Nov 8, 2025

r? compiler

@JonathanBrouwer JonathanBrouwer added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2025
@JonathanBrouwer
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2025
@rust-cloud-vms rust-cloud-vms bot force-pushed the a-lot-of-references-in-self branch from cd574ab to 7298174 Compare November 8, 2025 13:46
@rustbot
Copy link
Collaborator

rustbot commented Nov 8, 2025

⚠️ Warning ⚠️

@JonathanBrouwer
Copy link
Contributor

r=me after rebasing & ci green

@Kivooeo
Copy link
Member Author

Kivooeo commented Nov 8, 2025

Forget about rebase but I guess it shouldn't be a problem?

@JonathanBrouwer
Copy link
Contributor

There's an increased risk of soft-conflicts if you have an old base, but given how isolated this change is it should be fine.
@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit 7298174 has been approved by JonathanBrouwer

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants