diff options
| author | varkor <github@varkor.com> | 2019-04-25 21:12:17 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-04-25 21:12:17 +0100 |
| commit | 908a6399bcbc008a6d3b36b3db8724d7c93e890f (patch) | |
| tree | 5d967ca8c9f56bd4f8d166bb05eb2f238cac1933 /src | |
| parent | 102f7a8b26a549f095f7d075eae37189be2bdd5a (diff) | |
| download | rust-908a6399bcbc008a6d3b36b3db8724d7c93e890f.tar.gz rust-908a6399bcbc008a6d3b36b3db8724d7c93e890f.zip | |
Add a test for const parameters with type parameters as types
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/const-param-type-depends-on-type-param.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs new file mode 100644 index 00000000000..ca924695993 --- /dev/null +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs @@ -0,0 +1,7 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +pub struct Dependent<T, const X: T>([(); X]); //~ ERROR const parameters +//~^ ERROR parameter `T` is never used + +fn main() {} diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr new file mode 100644 index 00000000000..0722c2c99fe --- /dev/null +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr @@ -0,0 +1,24 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/const-param-type-depends-on-type-param.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error[E0671]: const parameters cannot depend on type parameters + --> $DIR/const-param-type-depends-on-type-param.rs:4:34 + | +LL | pub struct Dependent<T, const X: T>([(); X]); + | ^ const parameter depends on type parameter + +error[E0392]: parameter `T` is never used + --> $DIR/const-param-type-depends-on-type-param.rs:4:22 + | +LL | pub struct Dependent<T, const X: T>([(); X]); + | ^ unused parameter + | + = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0392, E0671. +For more information about an error, try `rustc --explain E0392`. |
