diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 10:02:19 +0100 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 10:02:33 +0100 |
| commit | a8310e202c236a43f6c9d9af877fd54a8abb461e (patch) | |
| tree | b42db01950cf35062d32824b14d178286d9e8a1a | |
| parent | dd78188185de99645178c75036415cbda55d553c (diff) | |
| download | rust-a8310e202c236a43f6c9d9af877fd54a8abb461e.tar.gz rust-a8310e202c236a43f6c9d9af877fd54a8abb461e.zip | |
add associated type bounds test
4 files changed, 71 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/associated-type-bound-fail.full.stderr b/src/test/ui/const-generics/associated-type-bound-fail.full.stderr new file mode 100644 index 00000000000..8ccbe5dee0e --- /dev/null +++ b/src/test/ui/const-generics/associated-type-bound-fail.full.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `u16: Bar<N>` is not satisfied + --> $DIR/associated-type-bound-fail.rs:14:5 + | +LL | type Assoc: Bar<N>; + | ------ required by this bound in `Foo::Assoc` +... +LL | type Assoc = u16; + | ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16` + | + = help: the following implementations were found: + <u16 as Bar<3_usize>> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/associated-type-bound-fail.min.stderr b/src/test/ui/const-generics/associated-type-bound-fail.min.stderr new file mode 100644 index 00000000000..8ccbe5dee0e --- /dev/null +++ b/src/test/ui/const-generics/associated-type-bound-fail.min.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `u16: Bar<N>` is not satisfied + --> $DIR/associated-type-bound-fail.rs:14:5 + | +LL | type Assoc: Bar<N>; + | ------ required by this bound in `Foo::Assoc` +... +LL | type Assoc = u16; + | ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16` + | + = help: the following implementations were found: + <u16 as Bar<3_usize>> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/associated-type-bound-fail.rs b/src/test/ui/const-generics/associated-type-bound-fail.rs new file mode 100644 index 00000000000..3440b1356c2 --- /dev/null +++ b/src/test/ui/const-generics/associated-type-bound-fail.rs @@ -0,0 +1,17 @@ +// revisions: full min +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] + +trait Bar<const N: usize> {} + +trait Foo<const N: usize> { + type Assoc: Bar<N>; +} + +impl Bar<3> for u16 {} +impl<const N: usize> Foo<N> for i16 { + type Assoc = u16; //~ ERROR the trait bound `u16: Bar<N>` +} + +fn main() {} diff --git a/src/test/ui/const-generics/associated-type-bound.rs b/src/test/ui/const-generics/associated-type-bound.rs new file mode 100644 index 00000000000..374a49194b1 --- /dev/null +++ b/src/test/ui/const-generics/associated-type-bound.rs @@ -0,0 +1,24 @@ +// run-pass +// revisions: full min +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] + +trait Bar<const N: usize> {} + +trait Foo<const N: usize> { + type Assoc: Bar<N>; +} + +impl<const N: usize> Bar<N> for u8 {} +impl Bar<3> for u16 {} + +impl<const N: usize> Foo<N> for i8 { + type Assoc = u8; +} + +impl Foo<3> for i16 { + type Assoc = u16; +} + +fn main() {} |
