diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2021-08-04 23:29:30 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2021-08-06 11:31:52 +0200 |
| commit | d0d49477755cead57aa20a4958562e7ca6e8f805 (patch) | |
| tree | 82a083a3e4e1f61a597eb5642308c824dad2b6be /src/test | |
| parent | 6be8a06bcf2e7c45db2f9e3dd3c9c0e282562a93 (diff) | |
| download | rust-d0d49477755cead57aa20a4958562e7ca6e8f805.tar.gz rust-d0d49477755cead57aa20a4958562e7ca6e8f805.zip | |
Add hint for unresolved associated trait items if the trait has a single item
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/associated-item/issue-87638.fixed | 22 | ||||
| -rw-r--r-- | src/test/ui/associated-item/issue-87638.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/associated-item/issue-87638.stderr | 27 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-22037.stderr | 7 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-19883.stderr | 8 |
5 files changed, 84 insertions, 2 deletions
diff --git a/src/test/ui/associated-item/issue-87638.fixed b/src/test/ui/associated-item/issue-87638.fixed new file mode 100644 index 00000000000..b689777685f --- /dev/null +++ b/src/test/ui/associated-item/issue-87638.fixed @@ -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 +} diff --git a/src/test/ui/associated-item/issue-87638.rs b/src/test/ui/associated-item/issue-87638.rs new file mode 100644 index 00000000000..5a60b20fdf3 --- /dev/null +++ b/src/test/ui/associated-item/issue-87638.rs @@ -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 +} diff --git a/src/test/ui/associated-item/issue-87638.stderr b/src/test/ui/associated-item/issue-87638.stderr new file mode 100644 index 00000000000..cf6083444b0 --- /dev/null +++ b/src/test/ui/associated-item/issue-87638.stderr @@ -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`. diff --git a/src/test/ui/associated-types/issue-22037.stderr b/src/test/ui/associated-types/issue-22037.stderr index 615628558f0..0e019f10f37 100644 --- a/src/test/ui/associated-types/issue-22037.stderr +++ b/src/test/ui/associated-types/issue-22037.stderr @@ -1,8 +1,13 @@ error[E0576]: cannot find associated type `X` in trait `A` --> $DIR/issue-22037.rs:3:33 | +LL | type Output; + | ------------ associated type `Output` defined here LL | fn a(&self) -> <Self as A>::X; - | ^ not found in `A` + | ^ + | | + | not found in `A` + | help: maybe you meant this associated type: `Output` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19883.stderr b/src/test/ui/issues/issue-19883.stderr index e370b2ec1cb..bd6a86b7420 100644 --- a/src/test/ui/issues/issue-19883.stderr +++ b/src/test/ui/issues/issue-19883.stderr @@ -1,8 +1,14 @@ error[E0576]: cannot find associated type `Dst` in trait `From` --> $DIR/issue-19883.rs:9:30 | +LL | type Output; + | ------------ associated type `Output` defined here +... LL | <Dst as From<Self>>::Dst - | ^^^ not found in `From` + | ^^^ + | | + | not found in `From` + | help: maybe you meant this associated type: `Output` error: aborting due to previous error |
