-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Suggest field typo through derefs #117110
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
5e56fb2
to
d3ceb6c
Compare
d3ceb6c
to
c715d93
Compare
} | ||
ty::Alias(ty::Opaque, _) => { | ||
self.suggest_await_on_field_access(&mut err, ident, base, base_ty.peel_refs()); |
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.
nit: can you please extract this whole block to a function and not make suggest_await_on_field_access
return a value, but instead put the functionality in suggest_await_on_field_access
, that is responsible for the return value, in this function?
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.
Changed.
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 didn't mean that you should get rid of the has_label
block, just that you either move the functionality that calculates has_label
to its own function. As an alternative you could also just put the logic that was responsible for calculating the return value of suggest_await_on_field_access
directly into the "has_label
block" instead of making suggest_await_on_field_access
have a return value.
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.
What do you think of the last commit instead? There's some duplication of the setting of the label, but less state to keep track of.
c715d93
to
bd8b50a
Compare
Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC rust-lang#78374 (comment)
When encountering a `Result<T, _>` or `Option<T>` where `T` has a field that's being accessed, suggest calling `.unwrap()` to get to the field.
bd8b50a
to
1ee37bf
Compare
@bors r+ rollup |
…=b-naber Suggest field typo through derefs Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC rust-lang#78374 (comment)
…=b-naber Suggest field typo through derefs Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC rust-lang#78374 (comment)
Rollup of 6 pull requests Successful merges: - rust-lang#116446 (Yeet `mir::Const::from_anon_const`) - rust-lang#116750 (Add Seek::seek_relative) - rust-lang#117110 (Suggest field typo through derefs) - rust-lang#117961 (Add `x suggest` entries for testing `mir-opt` and `coverage`) - rust-lang#118020 (Fix links to `From<{OwnedHandle, OwnedFd}> for std::process::Child{Stdin, Stdout, Stderr}` in 1.74 release notes) - rust-lang#118034 (bump few deps to fix unsoundness and drop few dup deps) r? `@ghost` `@rustbot` modify labels: rollup
…=b-naber Suggest field typo through derefs Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC rust-lang#78374 (comment)
Rollup of 5 pull requests Successful merges: - rust-lang#116750 (Add Seek::seek_relative) - rust-lang#117110 (Suggest field typo through derefs) - rust-lang#117961 (Add `x suggest` entries for testing `mir-opt` and `coverage`) - rust-lang#118020 (Fix links to `From<{OwnedHandle, OwnedFd}> for std::process::Child{Stdin, Stdout, Stderr}` in 1.74 release notes) - rust-lang#118034 (bump few deps to fix unsoundness and drop few dup deps) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#117110 - estebank:deref-field-suggestion, r=b-naber Suggest field typo through derefs Take into account implicit dereferences when suggesting fields. ``` error[E0609]: no field `longname` on type `Arc<S>` --> $DIR/suggest-field-through-deref.rs:10:15 | LL | let _ = x.longname; | ^^^^^^^^ help: a field with a similar name exists: `long_name` ``` CC rust-lang#78374 (comment)
Take into account implicit dereferences when suggesting fields.
CC #78374 (comment)