diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs deleted file mode 100644 index a0290361ed1f..000000000000 --- a/tests/crashes/101557.rs +++ /dev/null @@ -1,42 +0,0 @@ -//@ known-bug: #101557 -//@ compile-flags: -Copt-level=0 -#![feature(generic_const_exprs)] -use std::marker::PhantomData; - -trait Trait { - const CONST: usize; -} - -struct A { - _marker: PhantomData, -} - -impl Trait for [i8; N] { - const CONST: usize = N; -} - -impl From for A<[i8; N]> { - fn from(_: usize) -> Self { - todo!() - } -} - -impl From> for A { - fn from(_: A<[i8; T::CONST]>) -> Self { - todo!() - } -} - -fn f() -> A -where - [(); T::CONST]:, -{ - // Usage of `0` is arbitrary - let a = A::<[i8; T::CONST]>::from(0); - A::::from(a) -} - -fn main() { - // Usage of `1` is arbitrary - f::<[i8; 1]>(); -} diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs deleted file mode 100644 index 2e230f98d81d..000000000000 --- a/tests/crashes/119692.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ known-bug: #119692 -//@ compile-flags: -Copt-level=0 -#![allow(incomplete_features)] -#![feature(adt_const_params)] -#![feature(generic_const_exprs)] - -use std::ops::Add; - -#[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)] -pub struct Dimension; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)] -pub struct Quantity(pub(crate) S); - -impl Add> for Quantity -where - LHS: Add, -{ - type Output = Quantity<>::Output, D>; - fn add(self, rhs: Quantity) -> Self::Output { - Quantity(self.0 + rhs.0) - } -} - -impl Add for Quantity -where - LHS: Add, -{ - type Output = Quantity<>::Output, { Dimension }>; - fn add(self, rhs: RHS) -> Self::Output { - Quantity(self.0 + rhs) - } -} - -impl Add> for f32 { - type Output = Quantity; - fn add(self, rhs: Quantity) -> Self::Output { - Quantity(self + rhs.0) - } -} - -pub fn add(x: Quantity, y: Quantity) -> Quantity { - x + y -} - -fn main() { - add(Quantity::(1.0), Quantity(2.0)); -} diff --git a/tests/crashes/136859.rs b/tests/crashes/136859.rs deleted file mode 100644 index 2c926eea5e27..000000000000 --- a/tests/crashes/136859.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ known-bug: #136859 -#![feature(generic_const_exprs)] - -trait If {} -impl If for () {} - -trait IsZero { - type Answer; -} - -struct True; -struct False; - -impl IsZero for () -where (): If<{N == 0}> { - type Msg = True; -} - -trait Foobar {} - -impl Foobar for () -where (): IsZero {} - -impl Foobar<{{ N }}> for () -where (): IsZero {} - -fn main() {} diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs b/tests/crashes/155761-1.rs similarity index 55% rename from tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs rename to tests/crashes/155761-1.rs index 7fa189f9aac8..ed871ebf7191 100644 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs +++ b/tests/crashes/155761-1.rs @@ -1,12 +1,14 @@ -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@ ignore-compare-mode-next-solver (explicit revisions) +//@ known-bug: #155761 +//@compile-flags: -Znext-solver // A regression test for https://github.com/rust-lang/rust/issues/151329. // Ensures we do not trigger an ICE when normalization fails for a // projection on a trait object, even if the projection has the same // trait id as the object's bound. +// ICE again after moving to eager normalization in the next solver. +// #155761 has a simplified variant which causes ICE without eager normalization. + trait Foo { type V; } @@ -18,12 +20,8 @@ struct Bar { } impl Bar> { - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied fn event(&self) { - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied (self.callback)(any(), any()); - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - //~| ERROR: expected function } } diff --git a/tests/ui/const-generics/issues/issue-89304.rs b/tests/ui/const-generics/issues/issue-89304.rs index d5cbfc9300b1..e8167deec84e 100644 --- a/tests/ui/const-generics/issues/issue-89304.rs +++ b/tests/ui/const-generics/issues/issue-89304.rs @@ -1,17 +1,17 @@ -//@ check-pass - #![feature(generic_const_exprs)] #![allow(incomplete_features)] struct GenericStruct { val: i64 } impl From> for GenericStruct<{T + 1}> { +//~^ ERROR: conflicting implementations of trait `From>` for type `GenericStruct<_>` fn from(other: GenericStruct) -> Self { Self { val: other.val } } } impl From> for GenericStruct { +//~^ ERROR: conflicting implementations of trait `From>` for type `GenericStruct<_>` fn from(other: GenericStruct<{T + 1}>) -> Self { Self { val: other.val } } diff --git a/tests/ui/const-generics/issues/issue-89304.stderr b/tests/ui/const-generics/issues/issue-89304.stderr new file mode 100644 index 000000000000..cac8cd32915e --- /dev/null +++ b/tests/ui/const-generics/issues/issue-89304.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `From>` for type `GenericStruct<_>` + --> $DIR/issue-89304.rs:6:1 + | +LL | impl From> for GenericStruct<{T + 1}> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error[E0119]: conflicting implementations of trait `From>` for type `GenericStruct<_>` + --> $DIR/issue-89304.rs:13:1 + | +LL | impl From> for GenericStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs new file mode 100644 index 000000000000..302c48d17356 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs @@ -0,0 +1,22 @@ +//@compile-flags: -Znext-solver + +// Regression test for #151308 + +#![feature(lazy_type_alias)] +trait Trait { + type Associated; +} + +trait Generic {} + +type TraitObject = dyn Generic<::Associated>; +//~^ ERROR: the trait bound `i32: Trait` is not satisfied + +struct Wrap(TraitObject); +//~^ ERROR: the trait bound `i32: Trait` is not satisfied + +fn cast(x: *mut Wrap) { + x as *mut Wrap; +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr new file mode 100644 index 000000000000..5e857df955ad --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `i32: Trait` is not satisfied + --> $DIR/dont-ice-on-normalization-failure.rs:12:32 + | +LL | type TraitObject = dyn Generic<::Associated>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32` + | +help: this trait has no implementations, consider adding one + --> $DIR/dont-ice-on-normalization-failure.rs:6:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ + +error[E0277]: the trait bound `i32: Trait` is not satisfied + --> $DIR/dont-ice-on-normalization-failure.rs:15:13 + | +LL | struct Wrap(TraitObject); + | ^^^^^^^^^^^ the trait `Trait` is not implemented for `i32` + | +help: this trait has no implementations, consider adding one + --> $DIR/dont-ice-on-normalization-failure.rs:6:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr deleted file mode 100644 index 06bbc51e0339..000000000000 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 - | -LL | impl Bar> { - | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14 - | -LL | fn event(&self) { - | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ - -error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^-------------- - | | - | call expression requires function - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0618. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr deleted file mode 100644 index 06bbc51e0339..000000000000 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 - | -LL | impl Bar> { - | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14 - | -LL | fn event(&self) { - | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ - -error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^-------------- - | | - | call expression requires function - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0618. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs new file mode 100644 index 000000000000..ad401602a326 --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the first variant of trait-system-refactor-initiative#191 + +trait Indir: FnOnce(T) -> Self::Ret { + type Ret; +} +impl Indir for F where F: FnOnce(T) -> R { + type Ret = R; +} + +trait Mirror { + type Assoc<'a>; +} + +fn needs(_: impl for<'a> Indir>) {} + +fn test() where for<'a> T: Mirror = i32> { + needs::(|x| { x.to_string(); }); +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs new file mode 100644 index 000000000000..bbbbc5c3e50c --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs @@ -0,0 +1,19 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the third variant of trait-system-refactor-initiative#191 + +trait Ref<'a, F> { + type Input; +} + +impl<'a, F> Ref<'a, F> for u32 { + type Input = &'a u32; +} + +fn needs_super Fn(>::Input)>(_: F) {} + +fn main() { + needs_super(|_| {}); +} diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs new file mode 100644 index 000000000000..fb6297869356 --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs @@ -0,0 +1,23 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the fourth variant of trait-system-refactor-initiative#191 + +trait Trait { + type Assoc<'a>; +} + +impl Trait for () { + type Assoc<'a> = &'a (); +} + +fn foo(x: Option<*mut T>) -> for<'a> fn(<() as Trait>::Assoc<'a>) { + |_| () +} + +fn main() { + let mut x = None; + let mut y = foo(x); + x = Some(&mut y); +} diff --git a/tests/ui/wf/wf-normalization-sized.next.stderr b/tests/ui/wf/wf-normalization-sized.next.stderr deleted file mode 100644 index 804dd0a252d1..000000000000 --- a/tests/ui/wf/wf-normalization-sized.next.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time - --> $DIR/wf-normalization-sized.rs:19:11 - | -LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[[[[[u8]]]]]` - = note: slice and array elements must have `Sized` type - -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/wf-normalization-sized.rs:21:11 - | -LL | const _: as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by an implicit `Sized` bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-normalization-sized.rs b/tests/ui/wf/wf-normalization-sized.rs index e695fd93fb0e..fbe38975f46f 100644 --- a/tests/ui/wf/wf-normalization-sized.rs +++ b/tests/ui/wf/wf-normalization-sized.rs @@ -1,8 +1,8 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver //@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] check-pass -//@[current] known-bug: #100041 +//@ check-pass +//@ known-bug: #100041 // Should fail. Normalization can bypass well-formedness checking. // `[[[[[[u8]]]]]]` is not a well-formed type since size of type `[u8]` cannot @@ -17,8 +17,6 @@ impl WellUnformed for T { } const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); -//[next]~^ ERROR the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time const _: as WellUnformed>::RequestNormalize = (); -//[next]~^ ERROR the size for values of type `str` cannot be known at compilation time fn main() {}