diff options
| author | Robin Appelman <robin@icewind.nl> | 2022-03-27 20:45:08 +0200 |
|---|---|---|
| committer | Robin Appelman <robin@icewind.nl> | 2022-04-17 00:44:36 +0200 |
| commit | decc04dbfbfe240e649cd4f891ca14d2f501c0ff (patch) | |
| tree | 8c1adf1392bf09a02ddca5c0ce7ad8df20809a4a /src | |
| parent | 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 (diff) | |
| download | rust-decc04dbfbfe240e649cd4f891ca14d2f501c0ff.tar.gz rust-decc04dbfbfe240e649cd4f891ca14d2f501c0ff.zip | |
show suggestion to replace generic bounds with associated types in more cases
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-87493.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0107.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0107.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr | 13 |
4 files changed, 33 insertions, 10 deletions
diff --git a/src/test/ui/const-generics/issues/issue-87493.stderr b/src/test/ui/const-generics/issues/issue-87493.stderr index 8f92eeaffd1..f998c1187d8 100644 --- a/src/test/ui/const-generics/issues/issue-87493.stderr +++ b/src/test/ui/const-generics/issues/issue-87493.stderr @@ -13,7 +13,7 @@ error[E0107]: this trait takes 0 generic arguments but 1 generic argument was su --> $DIR/issue-87493.rs:8:8 | LL | T: MyTrait<Assoc == S::Assoc>, - | ^^^^^^^------------------- help: remove these generics + | ^^^^^^^ ----------------- help: replace the generic bound with the associated type: `Assoc = Assoc == S::Assoc` | | | expected 0 generic arguments | diff --git a/src/test/ui/error-codes/E0107.rs b/src/test/ui/error-codes/E0107.rs index 840700c9cc6..d369fc2a565 100644 --- a/src/test/ui/error-codes/E0107.rs +++ b/src/test/ui/error-codes/E0107.rs @@ -47,4 +47,14 @@ struct Baz<'a, 'b, 'c> { //~| HELP remove this lifetime argument } +pub trait T { + type A; + type B; +} + +fn trait_bound_generic<I: T<u8, u16>>(_i: I) { + //~^ ERROR this trait takes 0 generic arguments + //~| HELP replace the generic bounds with the associated types +} + fn main() {} diff --git a/src/test/ui/error-codes/E0107.stderr b/src/test/ui/error-codes/E0107.stderr index c90f85df967..5ca03b45d82 100644 --- a/src/test/ui/error-codes/E0107.stderr +++ b/src/test/ui/error-codes/E0107.stderr @@ -128,6 +128,22 @@ note: struct defined here, with 0 lifetime parameters LL | struct Quux<T>(T); | ^^^^ -error: aborting due to 9 previous errors +error[E0107]: this trait takes 0 generic arguments but 2 generic arguments were supplied + --> $DIR/E0107.rs:55:27 + | +LL | fn trait_bound_generic<I: T<u8, u16>>(_i: I) { + | ^ expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/E0107.rs:50:11 + | +LL | pub trait T { + | ^ +help: replace the generic bounds with the associated types + | +LL | fn trait_bound_generic<I: T<A = u8, B = u16>>(_i: I) { + | ~~~~~~ ~~~~~~~ + +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 5a158e5876a..5409e32c436 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -2,15 +2,17 @@ error[E0107]: this trait takes 2 generic arguments but 4 generic arguments were --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16 | LL | i: Box<dyn T<usize, usize, usize, usize, B=usize>>, - | ^ ------------ help: remove these generic arguments - | | - | expected 2 generic arguments + | ^ expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `X`, `Y` --> $DIR/use-type-argument-instead-of-assoc-type.rs:1:11 | LL | pub trait T<X, Y> { | ^ - - +help: replace the generic bounds with the associated types + | +LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>, + | ~~~~~~~~~ ~~~~~~~~~ error[E0191]: the value of the associated types `A` (from trait `T`), `C` (from trait `T`) must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16 @@ -23,11 +25,6 @@ LL | type C; ... LL | i: Box<dyn T<usize, usize, usize, usize, B=usize>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated types `A`, `C` must be specified - | -help: specify the associated types - | -LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>, - | ~~~~~~~~~ ~~~~~~~~~ error: aborting due to 2 previous errors |
