Add additional type info to mismatch err
This commit is contained in:
parent
3f5aee2d52
commit
be1ed00712
4 changed files with 79 additions and 32 deletions
13
src/test/ui/const-generics/diagnostics.rs
Normal file
13
src/test/ui/const-generics/diagnostics.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#![crate_type="lib"]
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct A<const N: u8>;
|
||||
trait Foo {}
|
||||
impl Foo for A<N> {}
|
||||
//~^ ERROR type provided when a constant
|
||||
//~| ERROR cannot find type
|
||||
|
||||
struct B<const N: u8>;
|
||||
impl<N> Foo for B<N> {}
|
||||
//~^ ERROR type provided when a constant
|
||||
27
src/test/ui/const-generics/diagnostics.stderr
Normal file
27
src/test/ui/const-generics/diagnostics.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
error[E0412]: cannot find type `N` in this scope
|
||||
--> $DIR/diagnostics.rs:7:16
|
||||
|
|
||||
LL | struct A<const N: u8>;
|
||||
| ---------------------- similarly named struct `A` defined here
|
||||
LL | trait Foo {}
|
||||
LL | impl Foo for A<N> {}
|
||||
| ^ help: a struct with a similar name exists: `A`
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/diagnostics.rs:7:16
|
||||
|
|
||||
LL | impl Foo for A<N> {}
|
||||
| ^
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/diagnostics.rs:12:19
|
||||
|
|
||||
LL | impl<N> Foo for B<N> {}
|
||||
| - ^
|
||||
| |
|
||||
| help: try changing to a const-generic parameter:: `const N: u8`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0412, E0747.
|
||||
For more information about an error, try `rustc --explain E0412`.
|
||||
|
|
@ -30,44 +30,24 @@ error[E0747]: type provided when a constant was expected
|
|||
|
|
||||
LL | let _: Example<CompileFlag::A, _> = Example { x: 0 };
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: if this generic argument was intended as a const parameter, try surrounding it with braces:
|
||||
|
|
||||
LL | let _: Example<{ CompileFlag::A }, _> = Example { x: 0 };
|
||||
| ^ ^
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/invalid-enum.rs:33:18
|
||||
|
|
||||
LL | let _: Example<Example::ASSOC_FLAG, _> = Example { x: 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: if this generic argument was intended as a const parameter, try surrounding it with braces:
|
||||
|
|
||||
LL | let _: Example<{ Example::ASSOC_FLAG }, _> = Example { x: 0 };
|
||||
| ^ ^
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/invalid-enum.rs:21:12
|
||||
|
|
||||
LL | test_1::<CompileFlag::A>();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: if this generic argument was intended as a const parameter, try surrounding it with braces:
|
||||
|
|
||||
LL | test_1::<{ CompileFlag::A }>();
|
||||
| ^ ^
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/invalid-enum.rs:25:15
|
||||
|
|
||||
LL | test_2::<_, CompileFlag::A>(0);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: if this generic argument was intended as a const parameter, try surrounding it with braces:
|
||||
|
|
||||
LL | test_2::<_, { CompileFlag::A }>(0);
|
||||
| ^ ^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue