forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#96372 - compiler-errors:field-method-sugges…
…t, r=oli-obk Suggest calling method on nested field when struct is missing method Similar to the suggestion to change `x.field` to `x.nested.field`, implement a similar suggestion for when `x.method()` should be replaced with `x.nested.method()`.
- Loading branch information
Showing
6 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
struct Kind; | ||
|
||
struct Ty { | ||
kind: Kind, | ||
} | ||
|
||
impl Ty { | ||
fn kind(&self) -> Kind { | ||
todo!() | ||
} | ||
} | ||
|
||
struct InferOk<T> { | ||
value: T, | ||
predicates: Vec<()>, | ||
} | ||
|
||
fn foo(i: InferOk<Ty>) { | ||
let k = i.kind(); | ||
//~^ no method named `kind` found for struct `InferOk` in the current scope | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0599]: no method named `kind` found for struct `InferOk` in the current scope | ||
--> $DIR/field-has-method.rs:19:15 | ||
| | ||
LL | struct InferOk<T> { | ||
| ----------------- method `kind` not found for this | ||
... | ||
LL | let k = i.kind(); | ||
| ^^^^ method not found in `InferOk<Ty>` | ||
| | ||
help: one of the expressions' fields has a method of the same name | ||
| | ||
LL | let k = i.value.kind(); | ||
| ++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |