diff options
| author | Ellen <supbscripter@gmail.com> | 2022-05-05 17:44:54 +0100 |
|---|---|---|
| committer | Ellen <supbscripter@gmail.com> | 2022-05-05 17:45:39 +0100 |
| commit | fea1d765033eada386ffc1684d47c00a48d104f1 (patch) | |
| tree | fef19174b45842ee05a51064217311a101fed588 /src/test/ui/const-generics/defaults | |
| parent | 4208c53ed695ddb822b6510e3faa0a46e591060e (diff) | |
| download | rust-fea1d765033eada386ffc1684d47c00a48d104f1.tar.gz rust-fea1d765033eada386ffc1684d47c00a48d104f1.zip | |
make `compare_generic_param_kinds` errors consistent
Diffstat (limited to 'src/test/ui/const-generics/defaults')
| -rw-r--r-- | src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.stderr | 75 |
2 files changed, 69 insertions, 24 deletions
diff --git a/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.rs b/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.rs index fd57060d5e7..5c9323261a9 100644 --- a/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.rs +++ b/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.rs @@ -19,7 +19,23 @@ trait Uwu { } impl Uwu for () { fn baz<const N: i32>() {} - //~^ error: method `baz` has an incompatible const parameter type for trait + //~^ error: method `baz` has an incompatible generic parameter for trait +} + +trait Aaaaaa { + fn bbbb<const N: u32, T>() {} +} +impl Aaaaaa for () { + fn bbbb<T, const N: u32>() {} + //~^ error: method `bbbb` has an incompatible generic parameter for trait +} + +trait Names { + fn abcd<T, const N: u32>() {} +} +impl Names for () { + fn abcd<const N: u32, T>() {} + //~^ error: method `abcd` has an incompatible generic parameter for trait } fn main() {} diff --git a/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.stderr b/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.stderr index cea8f4e50b0..a1ec8adec76 100644 --- a/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.stderr +++ b/src/test/ui/const-generics/defaults/mismatched_ty_const_in_trait_impl.stderr @@ -1,39 +1,68 @@ -error[E0053]: method `foo` has an incompatible generic parameter for trait +error[E0053]: method `foo` has an incompatible generic parameter for trait: `Trait` --> $DIR/mismatched_ty_const_in_trait_impl.rs:5:12 | -LL | fn foo<const M: u64>() {} - | ^^^^^^^^^^^^ - | -note: the trait impl specifies `M` is a const parameter of type `u64`, but the declaration in trait `Trait::foo` requires it is a type parameter - --> $DIR/mismatched_ty_const_in_trait_impl.rs:2:12 - | +LL | trait Trait { + | ----- LL | fn foo<U>() {} - | ^ + | - expected type parameter +LL | } +LL | impl Trait for () { + | ----------------- +LL | fn foo<const M: u64>() {} + | ^^^^^^^^^^^^ found const parameter with type `u64` -error[E0053]: method `bar` has an incompatible generic parameter for trait +error[E0053]: method `bar` has an incompatible generic parameter for trait: `Other` --> $DIR/mismatched_ty_const_in_trait_impl.rs:13:12 | -LL | fn bar<T>() {} - | ^ - | -note: the trait impl specifies `T` is a type parameter, but the declaration in trait `Other::bar` requires it is a const parameter of type `u8` - --> $DIR/mismatched_ty_const_in_trait_impl.rs:10:12 - | +LL | trait Other { + | ----- LL | fn bar<const M: u8>() {} - | ^^^^^^^^^^^ + | ----------- expected const parameter with type `u8` +LL | } +LL | impl Other for () { + | ----------------- +LL | fn bar<T>() {} + | ^ found type parameter -error[E0053]: method `baz` has an incompatible const parameter type for trait +error[E0053]: method `baz` has an incompatible generic parameter for trait: `Uwu` --> $DIR/mismatched_ty_const_in_trait_impl.rs:21:12 | +LL | trait Uwu { + | --- +LL | fn baz<const N: u32>() {} + | ------------ expected const parameter with type `u32` +LL | } +LL | impl Uwu for () { + | --------------- LL | fn baz<const N: i32>() {} - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ found const parameter with type `i32` + +error[E0053]: method `bbbb` has an incompatible generic parameter for trait: `Aaaaaa` + --> $DIR/mismatched_ty_const_in_trait_impl.rs:29:13 | -note: the const parameter `N` has type `i32`, but the declaration in trait `Uwu::baz` has type `u32` - --> $DIR/mismatched_ty_const_in_trait_impl.rs:18:12 +LL | trait Aaaaaa { + | ------ +LL | fn bbbb<const N: u32, T>() {} + | ------------ expected const parameter with type `u32` +LL | } +LL | impl Aaaaaa for () { + | ------------------ +LL | fn bbbb<T, const N: u32>() {} + | ^ found type parameter + +error[E0053]: method `abcd` has an incompatible generic parameter for trait: `Names` + --> $DIR/mismatched_ty_const_in_trait_impl.rs:37:13 | -LL | fn baz<const N: u32>() {} - | ^^^^^^^^^^^^ +LL | trait Names { + | ----- +LL | fn abcd<T, const N: u32>() {} + | - expected type parameter +LL | } +LL | impl Names for () { + | ----------------- +LL | fn abcd<const N: u32, T>() {} + | ^^^^^^^^^^^^ found const parameter with type `u32` -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0053`. |
