-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hint for unresolved associated trait items if the trait has a sin…
…gle item
- Loading branch information
Showing
7 changed files
with
172 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// run-rustfix | ||
|
||
trait Trait { | ||
const FOO: usize; | ||
|
||
type Target; | ||
} | ||
|
||
struct S; | ||
|
||
impl Trait for S { | ||
const FOO: usize = 0; | ||
type Target = (); | ||
} | ||
|
||
fn main() { | ||
let _: <S as Trait>::Target; //~ ERROR cannot find associated type `Output` in trait `Trait` | ||
//~^ HELP maybe you meant this associated type | ||
|
||
let _ = <S as Trait>::FOO; //~ ERROR cannot find method or associated constant `BAR` in trait `Trait` | ||
//~^ HELP maybe you meant this associated constant | ||
} |
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,22 @@ | ||
// run-rustfix | ||
|
||
trait Trait { | ||
const FOO: usize; | ||
|
||
type Target; | ||
} | ||
|
||
struct S; | ||
|
||
impl Trait for S { | ||
const FOO: usize = 0; | ||
type Target = (); | ||
} | ||
|
||
fn main() { | ||
let _: <S as Trait>::Output; //~ ERROR cannot find associated type `Output` in trait `Trait` | ||
//~^ HELP maybe you meant this associated type | ||
|
||
let _ = <S as Trait>::BAR; //~ ERROR cannot find method or associated constant `BAR` in trait `Trait` | ||
//~^ HELP maybe you meant this associated constant | ||
} |
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,27 @@ | ||
error[E0576]: cannot find associated type `Output` in trait `Trait` | ||
--> $DIR/issue-87638.rs:17:26 | ||
| | ||
LL | type Target; | ||
| ------------ associated type `Target` defined here | ||
... | ||
LL | let _: <S as Trait>::Output; | ||
| ^^^^^^ | ||
| | | ||
| not found in `Trait` | ||
| help: maybe you meant this associated type: `Target` | ||
|
||
error[E0576]: cannot find method or associated constant `BAR` in trait `Trait` | ||
--> $DIR/issue-87638.rs:20:27 | ||
| | ||
LL | const FOO: usize; | ||
| ----------------- associated constant `FOO` defined here | ||
... | ||
LL | let _ = <S as Trait>::BAR; | ||
| ^^^ | ||
| | | ||
| not found in `Trait` | ||
| help: maybe you meant this associated constant: `FOO` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0576`. |
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