diff options
Diffstat (limited to 'tests')
7 files changed, 128 insertions, 8 deletions
diff --git a/tests/crashes/140642.rs b/tests/crashes/140642.rs deleted file mode 100644 index ff75a6ec2f2..00000000000 --- a/tests/crashes/140642.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #140642 -#![feature(min_generic_const_args)] - -pub trait Tr<A> { - const SIZE: usize; -} - -fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} diff --git a/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs new file mode 100644 index 00000000000..59d034953d7 --- /dev/null +++ b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs @@ -0,0 +1,15 @@ +//@ edition:2021 +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +fn call_once<F>(_: impl FnOnce() -> F) {} + +fn main() { + let mut i = 0; + let c = async || { + i += 1; + }; + call_once(c); +} diff --git a/tests/ui/const-generics/mgca/projection-error.rs b/tests/ui/const-generics/mgca/projection-error.rs new file mode 100644 index 00000000000..d1c4fa8a492 --- /dev/null +++ b/tests/ui/const-generics/mgca/projection-error.rs @@ -0,0 +1,17 @@ +#![feature(min_generic_const_args)] +#![expect(incomplete_features)] + +// Regression test for #140642. Test that normalizing const aliases +// containing erroneous types normalizes to a const error instead of +// a type error. + + +pub trait Tr<A> { + const SIZE: usize; +} + +fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} +//~^ ERROR: cannot find type `T` in this scope +//~| ERROR: cannot find type `T` in this scope + +fn main() {} diff --git a/tests/ui/const-generics/mgca/projection-error.stderr b/tests/ui/const-generics/mgca/projection-error.stderr new file mode 100644 index 00000000000..e6888351da1 --- /dev/null +++ b/tests/ui/const-generics/mgca/projection-error.stderr @@ -0,0 +1,39 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/projection-error.rs:13:17 + | +LL | pub trait Tr<A> { + | --------------- similarly named trait `Tr` defined here +... +LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | ^ + | +help: a trait with a similar name exists + | +LL | fn mk_array(_x: Tr) -> [(); <T as Tr<bool>>::SIZE] {} + | + +help: you might be missing a type parameter + | +LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | +++ + +error[E0412]: cannot find type `T` in this scope + --> $DIR/projection-error.rs:13:29 + | +LL | pub trait Tr<A> { + | --------------- similarly named trait `Tr` defined here +... +LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | ^ + | +help: a trait with a similar name exists + | +LL | fn mk_array(_x: T) -> [(); <Tr as Tr<bool>>::SIZE] {} + | + +help: you might be missing a type parameter + | +LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | +++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr new file mode 100644 index 00000000000..a2cec972e4a --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/hr-projection-mismatch.rs:20:5 + | +LL | wrap::<_, Thing>(); + | ^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected reference `&'a _` + found reference `&_` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr b/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr new file mode 100644 index 00000000000..6ea0d43e153 --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr @@ -0,0 +1,20 @@ +error[E0271]: type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32` + --> $DIR/hr-projection-mismatch.rs:20:15 + | +LL | wrap::<_, Thing>(); + | ^^^^^ type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32` + | +note: types differ + --> $DIR/hr-projection-mismatch.rs:14:18 + | +LL | type Assoc = &'a i32; + | ^^^^^^^ +note: required by a bound in `wrap` + --> $DIR/hr-projection-mismatch.rs:17:33 + | +LL | fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {} + | ^^^^^^^^^ required by this bound in `wrap` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.rs b/tests/ui/mismatched_types/hr-projection-mismatch.rs new file mode 100644 index 00000000000..f96314a3fca --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.rs @@ -0,0 +1,25 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/rust/issues/141322>. + +trait Trait<'a> { + type Assoc; +} + +struct Thing; + +impl<'a> Trait<'a> for Thing { + type Assoc = &'a i32; +} + +fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {} + +fn foo() { + wrap::<_, Thing>(); + //[next]~^ ERROR type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32 + //[current]~^^ ERROR mismatched types +} + +fn main() {} |
