diff options
Diffstat (limited to 'tests/ui/const-generics')
4 files changed, 70 insertions, 0 deletions
diff --git a/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.rs b/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.rs new file mode 100644 index 00000000000..5ab443422df --- /dev/null +++ b/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/77919 +fn main() { + [1; <Multiply<Five, Five>>::VAL]; +} +trait TypeVal<T> { + const VAL: T; +} +struct Five; +struct Multiply<N, M> { + _n: PhantomData, //~ ERROR cannot find type `PhantomData` in this scope +} +impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} +//~^ ERROR cannot find type `VAL` in this scope +//~| ERROR not all trait items implemented diff --git a/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.stderr b/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.stderr new file mode 100644 index 00000000000..bac8abf46dc --- /dev/null +++ b/tests/ui/const-generics/trait-resolution-error-with-const-generics-77919.stderr @@ -0,0 +1,35 @@ +error[E0412]: cannot find type `PhantomData` in this scope + --> $DIR/trait-resolution-error-with-const-generics-77919.rs:10:9 + | +LL | _n: PhantomData, + | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | +LL + use std::marker::PhantomData; + | + +error[E0412]: cannot find type `VAL` in this scope + --> $DIR/trait-resolution-error-with-const-generics-77919.rs:12:63 + | +LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} + | ^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} + | +++++ + +error[E0046]: not all trait items implemented, missing: `VAL` + --> $DIR/trait-resolution-error-with-const-generics-77919.rs:12:1 + | +LL | const VAL: T; + | ------------ `VAL` from trait +... +LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0046, E0412. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/vec-macro-in-static-array.rs b/tests/ui/const-generics/vec-macro-in-static-array.rs new file mode 100644 index 00000000000..7a81836e255 --- /dev/null +++ b/tests/ui/const-generics/vec-macro-in-static-array.rs @@ -0,0 +1,8 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13446 + +// Used to cause ICE + +static VEC: [u32; 256] = vec![]; +//~^ ERROR mismatched types + +fn main() {} diff --git a/tests/ui/const-generics/vec-macro-in-static-array.stderr b/tests/ui/const-generics/vec-macro-in-static-array.stderr new file mode 100644 index 00000000000..de21f2274f3 --- /dev/null +++ b/tests/ui/const-generics/vec-macro-in-static-array.stderr @@ -0,0 +1,13 @@ +error[E0308]: mismatched types + --> $DIR/vec-macro-in-static-array.rs:5:26 + | +LL | static VEC: [u32; 256] = vec![]; + | ^^^^^^ expected `[u32; 256]`, found `Vec<_>` + | + = note: expected array `[u32; 256]` + found struct `Vec<_>` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. |
