add associated type bounds test
This commit is contained in:
parent
dd78188185
commit
a8310e202c
@ -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`.
|
@ -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`.
|
17
src/test/ui/const-generics/associated-type-bound-fail.rs
Normal file
17
src/test/ui/const-generics/associated-type-bound-fail.rs
Normal file
@ -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() {}
|
24
src/test/ui/const-generics/associated-type-bound.rs
Normal file
24
src/test/ui/const-generics/associated-type-bound.rs
Normal file
@ -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() {}
|
Loading…
Reference in New Issue
Block a user