-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tweak suggestion for this
-> self
#75509
Tweak suggestion for this
-> self
#75509
Conversation
r? @lcnr (rust_highfive has picked a reviewer for you, use r? to override) |
409e4f7
to
360388b
Compare
self.r | ||
.session | ||
.source_map() | ||
.span_through_char(*fn_span, '(') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be incorrect for fn test<const N: [u8; 3 / (7 + 2)]>()
. Not sure how easy this is to fix but it seems like getting an empty span after the opening paren of the argument list might be something we can put into a method after getting it right once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct. This is not the only place where that problem exists though, and wanted to keep this PR small by not threading a Span
from the AST all the way to resolve for this corner case. It seems to me that the cases where the suggestion is needed are unlikely to be using const generics, but even then they are not yet stable :)
I'll follow up in a bigger PR to refactor all the Span
wrangling cases at a later date, including this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the cases where the suggestion is needed are unlikely to be using const generics, but even then they are not yet stable :)
This won't even be a problem with min_const_generics
because arrays won't be allowed as const params at the start, so this isn't really a pressing issue, though it is something I should keep in mind before trying to stabilize it 😅
}; | ||
err.span_suggestion_verbose( | ||
span, | ||
"you are also missing a `self` receiver argument", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is a slightly too strong suggestion as there are often cases where I instead have to rename self
.
Maybe "you might be missing a self
receiver argument"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This suggestion is predicated on the previous one also being "correct". I can change the wording to something like "if you meant to use self
, then you are also...".
help: you are also missing a `self` receiver argument | ||
| | ||
LL | fn a(&self) -> A { | ||
| ^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is a slightly too strong suggestion as there are often cases where I instead have to rename self.
^
looks good to me @bors r+ rollup |
📌 Commit 4ecdec1 has been approved by |
Rollup of 17 pull requests Successful merges: - rust-lang#73943 (Document the unsafe keyword) - rust-lang#74062 (deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs) - rust-lang#74185 (Remove liballoc unneeded explicit link) - rust-lang#74192 (Improve documentation on process::Child.std* fields) - rust-lang#74409 (Change Debug impl of SocketAddr and IpAddr to match their Display output) - rust-lang#75195 (BTreeMap: purge innocent use of into_kv_mut) - rust-lang#75214 (Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`) - rust-lang#75432 (Switch to intra-doc links in `std::process`) - rust-lang#75482 (Clean up E0752 explanation) - rust-lang#75501 (Move to intra doc links in std::ffi) - rust-lang#75509 (Tweak suggestion for `this` -> `self`) - rust-lang#75511 (Do not emit E0228 when it is implied by E0106) - rust-lang#75515 (Bump std's libc version to 0.2.74) - rust-lang#75517 (Promotion and const interning comments) - rust-lang#75519 (BTreeMap: refactor splitpoint and move testing over to unit test) - rust-lang#75530 (Switch to intra-doc links in os/raw/*.md) - rust-lang#75531 (Migrate unit tests of btree collections to their native breeding ground) Failed merges: r? @ghost
this
in associatedfn
s always suggestself
.fn
lackingself
self
to assocfn
s when appropriateImprovements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust