Skip to content

Commit 45054d7

Browse files
authored
Rollup merge of #146305 - Kivooeo:a-lot-of-references-in-self, r=JonathanBrouwer
Add correct suggestion for multi-references for self type in method Currently the suggestion for this code ```rust fn main() {} struct A { field: i32, } impl A { fn f(&&self) {} } ``` looks like this, which is incorrect and missleading ```rust 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 ```rust 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
2 parents da08074 + 0266a08 commit 45054d7

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)