-
Notifications
You must be signed in to change notification settings - Fork 14k
Add correct suggestion for multi-references for self type in method #146305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
ac5c2a2 to
efd1bd0
Compare
|
I'm not sure if it's useful to give a special suggestion for this. |
efd1bd0 to
cd574ab
Compare
|
Let's try this one, I removed second suggestion with 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 |
|
r? compiler |
|
@rustbot author |
cd574ab to
7298174
Compare
|
|
r=me after rebasing & ci green |
|
Forget about rebase but I guess it shouldn't be a problem? |
|
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. |
Rollup of 22 pull requests Successful merges: - #128666 (Add `overflow_checks` intrinsic) - #146305 (Add correct suggestion for multi-references for self type in method) - #147179 ([DebugInfo] Fix container types failing to find template args) - #147743 (Show packed field alignment in mir_transform_unaligned_packed_ref) - #148079 (Rename `downcast_[ref|mut]_unchecked` -> `downcast_unchecked_[ref|mut]`) - #148084 (Optimize path components iteration on platforms that don't have prefixes) - #148126 (Fix rust stdlib build failing for VxWorks) - #148204 (Modify contributor email entries in .mailmap) - #148279 (rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names) - #148333 (constify result unwrap unchecked) - #148539 (Add Allocator proxy impls for Box, Rc, and Arc) - #148601 (`invalid_atomic_ordering`: also lint `update` & `try_update`) - #148612 (Add note for identifier with attempted hygiene violation) - #148613 (Switch hexagon targets to rust-lld) - #148619 (Enable std locking functions on AIX) - #148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`) - #148649 (don't completely reset `HeadUsages`) - #148673 (Remove a remnant of `dyn*` from the parser) - #148675 (Remove eslint-js from npm dependencies) - #148680 (Recover `[T: N]` as `[T; N]`) - #148688 (Remove unused argument `features` from `eval_config_entry`) - #148711 (Use the current lint note id when parsing `cfg!()`) r? `@ghost` `@rustbot` modify labels: rollup
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
Currently the suggestion for this code
looks like this, which is incorrect and missleading
So this fixes it and make more correct suggestions
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