diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/associated-types/issue-59324.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-59324.stderr | 69 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-67684.rs | 62 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-69398.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-71113.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-82079.rs | 121 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-85103.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-85103.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-88856.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-91231.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-91234.rs | 13 |
11 files changed, 394 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/issue-59324.rs b/src/test/ui/associated-types/issue-59324.rs new file mode 100644 index 00000000000..9e68e9e7751 --- /dev/null +++ b/src/test/ui/associated-types/issue-59324.rs @@ -0,0 +1,26 @@ +trait NotFoo {} + +pub trait Foo: NotFoo { + type OnlyFoo; +} + +pub trait Service { + type AssocType; +} + +pub trait ThriftService<Bug: NotFoo>: +//~^ ERROR the trait bound `Bug: Foo` is not satisfied +//~| ERROR the trait bound `Bug: Foo` is not satisfied + Service<AssocType = <Bug as Foo>::OnlyFoo> +{ + fn get_service( + //~^ ERROR the trait bound `Bug: Foo` is not satisfied + //~| ERROR the trait bound `Bug: Foo` is not satisfied + &self, + ) -> Self::AssocType; +} + +fn with_factory<H>(factory: dyn ThriftService<()>) {} +//~^ ERROR the trait bound `(): Foo` is not satisfied + +fn main() {} diff --git a/src/test/ui/associated-types/issue-59324.stderr b/src/test/ui/associated-types/issue-59324.stderr new file mode 100644 index 00000000000..2f430d3055e --- /dev/null +++ b/src/test/ui/associated-types/issue-59324.stderr @@ -0,0 +1,69 @@ +error[E0277]: the trait bound `Bug: Foo` is not satisfied + --> $DIR/issue-59324.rs:11:1 + | +LL | / pub trait ThriftService<Bug: NotFoo>: +LL | | +LL | | +LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> +... | +LL | | ) -> Self::AssocType; +LL | | } + | |_^ the trait `Foo` is not implemented for `Bug` + | +help: consider further restricting this bound + | +LL | pub trait ThriftService<Bug: NotFoo + Foo>: + | +++++ + +error[E0277]: the trait bound `Bug: Foo` is not satisfied + --> $DIR/issue-59324.rs:11:1 + | +LL | / pub trait ThriftService<Bug: NotFoo>: +LL | | +LL | | +LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> +... | +LL | | ) -> Self::AssocType; +LL | | } + | |_^ the trait `Foo` is not implemented for `Bug` + | +help: consider further restricting this bound + | +LL | pub trait ThriftService<Bug: NotFoo + Foo>: + | +++++ + +error[E0277]: the trait bound `Bug: Foo` is not satisfied + --> $DIR/issue-59324.rs:16:5 + | +LL | / fn get_service( +LL | | +LL | | +LL | | &self, +LL | | ) -> Self::AssocType; + | |_________________________^ the trait `Foo` is not implemented for `Bug` + | +help: consider further restricting this bound + | +LL | pub trait ThriftService<Bug: NotFoo + Foo>: + | +++++ + +error[E0277]: the trait bound `Bug: Foo` is not satisfied + --> $DIR/issue-59324.rs:16:8 + | +LL | fn get_service( + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug` + | +help: consider further restricting this bound + | +LL | pub trait ThriftService<Bug: NotFoo + Foo>: + | +++++ + +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/issue-59324.rs:23:29 + | +LL | fn with_factory<H>(factory: dyn ThriftService<()>) {} + | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-67684.rs b/src/test/ui/associated-types/issue-67684.rs new file mode 100644 index 00000000000..49efe8a1bda --- /dev/null +++ b/src/test/ui/associated-types/issue-67684.rs @@ -0,0 +1,62 @@ +// check-pass + +#![allow(dead_code)] + +trait ParseError { + type StreamError; +} + +impl<T> ParseError for T { + type StreamError = (); +} + +trait Stream { + type Item; + type Error: ParseError; +} + +trait Parser +where + <Self as Parser>::PartialState: Default, +{ + type PartialState; + fn parse_mode(_: &Self, _: Self::PartialState) { + loop {} + } +} + +impl Stream for () { + type Item = (); + type Error = (); +} + +impl Parser for () { + type PartialState = (); +} + +struct AndThen<A, B>(core::marker::PhantomData<(A, B)>); + +impl<A, B> Parser for AndThen<A, B> +where + A: Stream, + B: Into<<A::Error as ParseError>::StreamError>, +{ + type PartialState = (); +} + +fn expr<A>() -> impl Parser +where + A: Stream<Error = <A as Stream>::Item>, +{ + AndThen::<A, ()>(core::marker::PhantomData) +} + +fn parse_mode_impl<A>() +where + <A as Stream>::Error: ParseError, + A: Stream<Error = <A as Stream>::Item>, +{ + Parser::parse_mode(&expr::<A>(), Default::default()) +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-69398.rs b/src/test/ui/associated-types/issue-69398.rs new file mode 100644 index 00000000000..ca3d66b1c8e --- /dev/null +++ b/src/test/ui/associated-types/issue-69398.rs @@ -0,0 +1,21 @@ +// check-pass + +pub trait Foo { + type Bar; +} + +pub trait Broken { + type Assoc; + fn broken(&self) where Self::Assoc: Foo; +} + +impl<T> Broken for T { + type Assoc = (); + fn broken(&self) where Self::Assoc: Foo { + let _x: <Self::Assoc as Foo>::Bar; + } +} + +fn main() { + let _m: &dyn Broken<Assoc=()> = &(); +} diff --git a/src/test/ui/associated-types/issue-71113.rs b/src/test/ui/associated-types/issue-71113.rs new file mode 100644 index 00000000000..48de89127f4 --- /dev/null +++ b/src/test/ui/associated-types/issue-71113.rs @@ -0,0 +1,16 @@ +// check-pass + +use std::borrow::Cow; + +enum _Recursive<'a> +where + Self: ToOwned<Owned=Box<Self>> +{ + Variant(MyCow<'a, _Recursive<'a>>), +} + +pub struct Wrapper<T>(T); + +pub struct MyCow<'a, T: ToOwned<Owned=Box<T>> + 'a>(Wrapper<Cow<'a, T>>); + +fn main() {} diff --git a/src/test/ui/associated-types/issue-82079.rs b/src/test/ui/associated-types/issue-82079.rs new file mode 100644 index 00000000000..590c799c2d7 --- /dev/null +++ b/src/test/ui/associated-types/issue-82079.rs @@ -0,0 +1,121 @@ +// check-pass + +mod convenience_operators { + use crate::{Op, Relation}; + use std::ops::AddAssign; + use std::ops::Mul; + + impl<C: Op> Relation<C> { + pub fn map<F: Fn(C::D) -> D2 + 'static, D2: 'static>( + self, + f: F, + ) -> Relation<impl Op<D = D2, R = C::R>> { + self.map_dr(move |x, r| (f(x), r)) + } + } + + impl<K: 'static, V: 'static, C: Op<D = (K, V)>> Relation<C> { + pub fn semijoin<C2: Op<D = K, R = R2>, R2, R3: AddAssign<R3>>( + self, + other: Relation<C2>, + ) -> Relation<impl Op<D = C::D, R = R3>> + where + C::R: Mul<R2, Output = R3>, + { + self.join(other.map(|x| (x, ()))).map(|(k, x, ())| (k, x)) + } + } +} + +mod core { + mod operator { + mod join { + use super::Op; + use crate::core::Relation; + use std::ops::{AddAssign, Mul}; + struct Join<LC, RC> { + _left: LC, + _right: RC, + } + impl< + LC: Op<D = (K, LD), R = LR>, + RC: Op<D = (K, RD), R = RR>, + K: 'static, + LD: 'static, + LR: AddAssign<LR> + Mul<RR, Output = OR>, + RD: 'static, + RR: AddAssign<RR>, + OR: AddAssign<OR>, + > Op for Join<LC, RC> + { + type D = (K, LD, RD); + type R = OR; + } + impl<K: 'static, D: 'static, C: Op<D = (K, D)>> Relation<C> { + pub fn join<C2: Op<D = (K, D2)>, D2: 'static, OR: AddAssign<OR>>( + self, + other: Relation<C2>, + ) -> Relation<impl Op<D = (K, D, D2), R = OR>> + where + C::R: Mul<C2::R, Output = OR>, + { + Relation { + inner: Join { + _left: self.inner, + _right: other.inner, + }, + } + } + } + } + mod map { + use super::Op; + use crate::core::Relation; + use std::ops::AddAssign; + struct Map<C, MF> { + _inner: C, + _op: MF, + } + impl< + D1, + R1, + D2: 'static, + R2: AddAssign<R2>, + C: Op<D = D1, R = R1>, + MF: Fn(D1, R1) -> (D2, R2), + > Op for Map<C, MF> + { + type D = D2; + type R = R2; + } + impl<C: Op> Relation<C> { + pub fn map_dr<F: Fn(C::D, C::R) -> (D2, R2), D2: 'static, R2: AddAssign<R2>>( + self, + f: F, + ) -> Relation<impl Op<D = D2, R = R2>> { + Relation { + inner: Map { + _inner: self.inner, + _op: f, + }, + } + } + } + } + use std::ops::AddAssign; + pub trait Op { + type D: 'static; + type R: AddAssign<Self::R>; + } + } + pub use self::operator::Op; + #[derive(Clone)] + pub struct Relation<C> { + inner: C, + } +} + +use self::core::Op; +pub use self::core::Relation; + +fn main() {} diff --git a/src/test/ui/associated-types/issue-85103.rs b/src/test/ui/associated-types/issue-85103.rs new file mode 100644 index 00000000000..c5e13856178 --- /dev/null +++ b/src/test/ui/associated-types/issue-85103.rs @@ -0,0 +1,9 @@ +#![feature(rustc_attrs)] + +use std::borrow::Cow; + +#[rustc_layout(debug)] +type Edges<'a, E> = Cow<'a, [E]>; +//~^ ERROR layout error: NormalizationFailure + +fn main() {} diff --git a/src/test/ui/associated-types/issue-85103.stderr b/src/test/ui/associated-types/issue-85103.stderr new file mode 100644 index 00000000000..142f3c411ec --- /dev/null +++ b/src/test/ui/associated-types/issue-85103.stderr @@ -0,0 +1,8 @@ +error: layout error: NormalizationFailure(<[E] as std::borrow::ToOwned>::Owned, Type(<[E] as std::borrow::ToOwned>::Owned)) + --> $DIR/issue-85103.rs:6:1 + | +LL | type Edges<'a, E> = Cow<'a, [E]>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/associated-types/issue-88856.rs b/src/test/ui/associated-types/issue-88856.rs new file mode 100644 index 00000000000..7cae7c71cd2 --- /dev/null +++ b/src/test/ui/associated-types/issue-88856.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Trait{ + type R; + fn func(self)->Self::R; +} + +pub struct TraitImpl<const N:usize>(pub i32); + +impl<const N:usize> Trait for TraitImpl<N> +where [();N/2]:, +{ + type R = Self; + fn func(self)->Self::R { + self + } +} + +fn sample<P,Convert>(p:P,f:Convert) -> i32 +where + P:Trait,Convert:Fn(P::R)->i32 +{ + f(p.func()) +} + +fn main() { + let t = TraitImpl::<10>(4); + sample(t,|x|x.0); +} diff --git a/src/test/ui/associated-types/issue-91231.rs b/src/test/ui/associated-types/issue-91231.rs new file mode 100644 index 00000000000..3c1cb81f097 --- /dev/null +++ b/src/test/ui/associated-types/issue-91231.rs @@ -0,0 +1,17 @@ +// check-pass + +#![feature(extern_types)] +#![allow(dead_code)] + +extern { + type Extern; +} + +trait Trait { + type Type; +} + +#[inline] +fn f<'a>(_: <&'a Extern as Trait>::Type) where &'a Extern: Trait {} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-91234.rs b/src/test/ui/associated-types/issue-91234.rs new file mode 100644 index 00000000000..2f6c2d3aebd --- /dev/null +++ b/src/test/ui/associated-types/issue-91234.rs @@ -0,0 +1,13 @@ +// check-pass + +struct Struct; + +trait Trait { + type Type; +} + +enum Enum<'a> where &'a Struct: Trait { + Variant(<&'a Struct as Trait>::Type) +} + +fn main() {} |
