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` is not satisfied + --> $DIR/associated-type-bound-fail.rs:14:5 + | +LL | type Assoc: Bar; + | ------ required by this bound in `Foo::Assoc` +... +LL | type Assoc = u16; + | ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `u16` + | + = help: the following implementations were found: + > + +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` is not satisfied + --> $DIR/associated-type-bound-fail.rs:14:5 + | +LL | type Assoc: Bar; + | ------ required by this bound in `Foo::Assoc` +... +LL | type Assoc = u16; + | ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `u16` + | + = help: the following implementations were found: + > + +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 {} + +trait Foo { + type Assoc: Bar; +} + +impl Bar<3> for u16 {} +impl Foo for i16 { + type Assoc = u16; //~ ERROR the trait bound `u16: Bar` +} + +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 {} + +trait Foo { + type Assoc: Bar; +} + +impl Bar for u8 {} +impl Bar<3> for u16 {} + +impl Foo for i8 { + type Assoc = u8; +} + +impl Foo<3> for i16 { + type Assoc = u16; +} + +fn main() {}