diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-25 17:05:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-25 17:05:34 +0100 |
| commit | 877f29363daffe7734bcfb9efbc32b9a06251465 (patch) | |
| tree | a85f7fad39ad46ae31a4dfee1682d0f8d4b899bb /tests | |
| parent | 9b4ee1be9e7317ef3f698423e584188518fcdc5c (diff) | |
| parent | e4d816e66c9de3e78a330cd27287c10b831b1c14 (diff) | |
| download | rust-877f29363daffe7734bcfb9efbc32b9a06251465.tar.gz rust-877f29363daffe7734bcfb9efbc32b9a06251465.zip | |
Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkov
add even more tests! Fixes https://github.com/rust-lang/rust/issues/109869 Fixes https://github.com/rust-lang/rust/issues/110453 Fixes https://github.com/rust-lang/rust/issues/109020 Fixes https://github.com/rust-lang/rust/issues/108580 Fixes https://github.com/rust-lang/rust/issues/108220 Fixes https://github.com/rust-lang/rust/issues/113045 Fixes https://github.com/rust-lang/rust/issues/113133 Fixes https://github.com/rust-lang/rust/issues/114464 Fixes https://github.com/rust-lang/rust/issues/116599 Fixes https://github.com/rust-lang/rust/issues/119731
Diffstat (limited to 'tests')
23 files changed, 526 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs new file mode 100644 index 00000000000..f58fd12e4d3 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs @@ -0,0 +1,17 @@ +// ICE cannot convert Refree.. to a region vid +// issue: rust-lang/rust#114464 + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn test<const N: usize>() {} + +fn wow<'a>() { + test::<{ + let _: &'a (); + //~^ ERROR cannot capture late-bound lifetime in constant + 3 + }>(); +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr new file mode 100644 index 00000000000..a234c5e129d --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr @@ -0,0 +1,11 @@ +error: cannot capture late-bound lifetime in constant + --> $DIR/convert-refree-region-vid-ice-114464.rs:11:17 + | +LL | fn wow<'a>() { + | -- lifetime defined here +LL | test::<{ +LL | let _: &'a (); + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs new file mode 100644 index 00000000000..5673f1dd073 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs @@ -0,0 +1,13 @@ +// ICE no entry found for key generics_of +// issue: rust-lang/rust#113133 + +#![allow(incomplete_features)] +#![feature(generic_const_exprs, non_lifetime_binders)] + +pub fn foo() +where + for<const N: usize = { const fn bar() {} bar(); 1 }> ():, + //~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders +{} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr new file mode 100644 index 00000000000..5924a673da9 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr @@ -0,0 +1,8 @@ +error: defaults for generic parameters are not allowed in `for<...>` binders + --> $DIR/no-entry-found-for-key-ice-gce-nlb-113133.rs:9:9 + | +LL | for<const N: usize = { const fn bar() {} bar(); 1 }> ():, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs new file mode 100644 index 00000000000..51cae20df84 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs @@ -0,0 +1,39 @@ +// rust-lang/rust#119731 +// ICE ... unevaluated constant UnevaluatedConst + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +mod v20 { + const v4: usize = 512; + pub type v11 = [[usize; v4]; v4]; + //~^ WARN type `v11` should have an upper camel case name + const v2: v11 = [[256; v4]; v4]; + + const v0: [[usize; v4]; v4] = v6(v8); + //~^ ERROR cannot find value `v8` in this scope + //~| ERROR cannot find function `v6` in this scope + pub struct v17<const v10: usize, const v7: v11> { + //~^ WARN type `v17` should have an upper camel case name + //~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter + _p: (), + } + + impl v17<512, v0> { + pub const fn v21() -> v18 {} + //~^ ERROR cannot find type `v18` in this scope + } + + impl<const v10: usize> v17<v10, v2> { + //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + pub const fn v21() -> v18 { + //~^ ERROR cannot find type `v18` in this scope + v18 { _p: () } + //~^ ERROR cannot find struct, variant or union type `v18` in this scope + } + } +} +pub use v20::{v13, v17}; +//~^ ERROR unresolved import `v20::v13` +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr new file mode 100644 index 00000000000..39f022fbee9 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -0,0 +1,92 @@ +error[E0432]: unresolved import `v20::v13` + --> $DIR/unevaluated-const-ice-119731.rs:37:15 + | +LL | pub use v20::{v13, v17}; + | ^^^ + | | + | no `v13` in `v20` + | help: a similar name exists in the module: `v11` + +error[E0425]: cannot find value `v8` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:13:38 + | +LL | const v0: [[usize; v4]; v4] = v6(v8); + | ^^ not found in this scope + +error[E0412]: cannot find type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:23:31 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | pub const fn v21() -> v18 {} + | ^^^ help: a type alias with a similar name exists: `v11` + +error[E0412]: cannot find type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:30:31 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | pub const fn v21() -> v18 { + | ^^^ help: a type alias with a similar name exists: `v11` + +error[E0422]: cannot find struct, variant or union type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:32:13 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | v18 { _p: () } + | ^^^ help: a type alias with a similar name exists: `v11` + +warning: type `v11` should have an upper camel case name + --> $DIR/unevaluated-const-ice-119731.rs:9:14 + | +LL | pub type v11 = [[usize; v4]; v4]; + | ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V11` + | + = note: `#[warn(non_camel_case_types)]` on by default + +warning: type `v17` should have an upper camel case name + --> $DIR/unevaluated-const-ice-119731.rs:16:16 + | +LL | pub struct v17<const v10: usize, const v7: v11> { + | ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17` + +error[E0425]: cannot find function `v6` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:13:35 + | +LL | const v0: [[usize; v4]; v4] = v6(v8); + | ^^ not found in this scope + +error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter + --> $DIR/unevaluated-const-ice-119731.rs:16:48 + | +LL | pub struct v17<const v10: usize, const v7: v11> { + | ^^^ + | + = note: the only supported types are integers, `bool` and `char` +help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + | +LL + #![feature(adt_const_params)] + | + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + --> $DIR/unevaluated-const-ice-119731.rs:27:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + --> $DIR/unevaluated-const-ice-119731.rs:27:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 9 previous errors; 2 warnings emitted + +Some errors have detailed explanations: E0412, E0422, E0425, E0432. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs b/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs new file mode 100644 index 00000000000..f5babb67b56 --- /dev/null +++ b/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs @@ -0,0 +1,35 @@ +// ICE assertion failed: matches!(self.def_kind(ct.def.did), DefKind :: AnonConst) +// issue: rust-lang/rust#108220 +//@ check-pass + +#![feature(associated_const_equality)] +#![allow(unused)] + +use std::marker::PhantomData; + +pub struct NoPin; + +pub trait SetAlternate<const A: u8> {} + +impl SetAlternate<0> for NoPin {} + +pub trait PinA<PER> { + const A: u8; +} + +impl<PER> PinA<PER> for NoPin { + const A: u8 = 0; +} + +pub trait Pins<USART> {} + +impl<USART, T, const TA: u8> Pins<USART> for T where + T: PinA<USART, A = { TA }> + SetAlternate<TA> +{ +} + +struct Serial<USART>(PhantomData<USART>); + +impl<USART> Serial<USART> where NoPin: Pins<USART> {} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs new file mode 100644 index 00000000000..bb10701cf6f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs @@ -0,0 +1,16 @@ +// ICE expected ReFree to map to ReEarlyBound +// issue: rust-lang/rust#108580 +//@ check-pass + +trait Foo { + fn bar(&self) -> impl Iterator<Item = impl Sized> + '_; +} + +impl Foo for () { + fn bar(&self) -> impl Iterator + '_ { + //~^ WARN impl trait in impl method signature does not match trait method signature + vec![()].into_iter() + } +} + +pub fn main() {} diff --git a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr new file mode 100644 index 00000000000..94f068cabaa --- /dev/null +++ b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr @@ -0,0 +1,19 @@ +warning: impl trait in impl method signature does not match trait method signature + --> $DIR/expeced-refree-to-map-to-reearlybound-ice-108580.rs:10:22 + | +LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_; + | ------------------------------------- return type from trait method defined here +... +LL | fn bar(&self) -> impl Iterator + '_ { + | ^^^^^^^^^^^^^^^^^^ + | + = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate + = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information + = note: `#[warn(refining_impl_trait_internal)]` on by default +help: replace the return type so that it matches the trait + | +LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +warning: 1 warning emitted + diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs new file mode 100644 index 00000000000..0b2e63bfcf7 --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs @@ -0,0 +1,18 @@ +// ICE in mir building with captured value of unresolved type +// None in compiler/rustc_mir_build/src/build/expr/as_place.rs +// issue: rust-lang/rust#110453 +//@ edition:2021 + +#![crate_type="lib"] + +pub struct B; +pub fn a() -> B { B } + +mod handlers { + pub struct C(B); + //~^ ERROR cannot find type `B` in this scope + pub fn c() -> impl Fn() -> C { + let a1 = (); + || C((crate::a(), a1).into()) + } +} diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr new file mode 100644 index 00000000000..468da0227d3 --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr @@ -0,0 +1,14 @@ +error[E0412]: cannot find type `B` in this scope + --> $DIR/mir-build-2021-closure-capture-ice-110453-1.rs:12:18 + | +LL | pub struct C(B); + | ^ not found in this scope + | +help: consider importing this struct + | +LL + use crate::B; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs new file mode 100644 index 00000000000..d63ccc6651c --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs @@ -0,0 +1,11 @@ +// ICE in mir building with captured value of unresolved type +// None in compiler/rustc_mir_build/src/build/expr/as_place.rs +// issue: rust-lang/rust#110453 +//@ edition:2021 + +#![crate_type="lib"] + +pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 { +//~^ ERROR cannot find type `as_str` in this scope + move |a| f(a * 2) +} diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr new file mode 100644 index 00000000000..8fe4981eb3f --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `as_str` in this scope + --> $DIR/mir-build-2021-closure-capture-ice-110453-2.rs:8:47 + | +LL | pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 { + | ^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/nll/unexpected-inference-var-ice-116599.rs b/tests/ui/nll/unexpected-inference-var-ice-116599.rs new file mode 100644 index 00000000000..53eeba23224 --- /dev/null +++ b/tests/ui/nll/unexpected-inference-var-ice-116599.rs @@ -0,0 +1,44 @@ +// ICE unexpected inference var +// issue: rust-lang/rust#116599 +//@ check-pass + +pub trait EvaluateConstMethods { + type Trait: TraitWithConstMethods; + + /// **This block breaks** + const DATA_3: Data3 = { + <<<Self::Trait as TraitWithConstMethods>::Method2 as ConstFn<_, _>>::Body< + <<Self::Trait as TraitWithConstMethods>::Method1 as ConstFn<_, _>>::Body<ContainsData1>, + > as Contains<_>>::ITEM + }; +} + +pub trait TraitWithConstMethods { + /// "const trait method" of signature `fn(Data1) -> Data2` + type Method1: ConstFn<Data1, Data2>; + + /// "const trait method" of signature `fn(Data2) -> Data3` + type Method2: ConstFn<Data2, Data3>; +} + +/// A trait which tries to implement const methods in traits +pub trait ConstFn<Arg, Ret> { + type Body<T: Contains<Arg>>: Contains<Ret>; +} + +/// A ZST which represents / "contains" a const value which can be pass to a [`ConstFn`] +pub trait Contains<T> { + const ITEM: T; +} + +pub struct ContainsData1; +impl Contains<Data1> for ContainsData1 { + const ITEM: Data1 = Data1 {}; +} + +// Arbitrary data +pub struct Data1 {} +pub struct Data2 {} +pub struct Data3 {} + +pub fn main() {} diff --git a/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs new file mode 100644 index 00000000000..6f0f233b870 --- /dev/null +++ b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs @@ -0,0 +1,15 @@ +// ICE min_specialization: +// Ok(['?0, Const { ty: usize, kind: Leaf(0x0000000000000000) }]) is not fully resolved +// issue: rust-lang/rust#113045 + +#![feature(min_specialization)] + +trait X {} + +impl<'a, const N: usize> X for [(); N] {} + +impl<'a, Unconstrained> X for [(); 0] {} +//~^ ERROR the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates +//~| ERROR specialization impl does not specialize any associated items + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr new file mode 100644 index 00000000000..acbdb9b0a30 --- /dev/null +++ b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr @@ -0,0 +1,21 @@ +error[E0207]: the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates + --> $DIR/ice-const-not-fully-resolved-113045.rs:11:10 + | +LL | impl<'a, Unconstrained> X for [(); 0] {} + | ^^^^^^^^^^^^^ unconstrained type parameter + +error: specialization impl does not specialize any associated items + --> $DIR/ice-const-not-fully-resolved-113045.rs:11:1 + | +LL | impl<'a, Unconstrained> X for [(); 0] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl is a specialization of this impl + --> $DIR/ice-const-not-fully-resolved-113045.rs:9:1 + | +LL | impl<'a, const N: usize> X for [(); N] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs new file mode 100644 index 00000000000..5cccda62608 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs @@ -0,0 +1,21 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +type Spanned<T> = (T, ()); + +trait Span<T> {} + +impl<T> Span<T> for (T, ()) {} + +impl<F, T: From<F>> From<Spanned<F>> for dyn Span<T> +where + Self: Sized +{ + fn from((from, ()): Spanned<F>) -> Self { + (T::from(from), ()) + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr new file mode 100644 index 00000000000..d43c9c01821 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs:16:9 + | +LL | fn from((from, ()): Spanned<F>) -> Self { + | ---- expected `(dyn Span<T> + 'static)` because of return type +LL | (T::from(from), ()) + | ^^^^^^^^^^^^^^^^^^^ expected `dyn Span`, found `(T, ())` + | + = note: expected trait object `(dyn Span<T> + 'static)` + found tuple `(T, ())` + = help: `(T, ())` implements `Span` so you could box the found value and coerce it to the trait object `Box<dyn Span>`, you will have to change the expected type as well +help: call `Into::into` on this expression to convert `(T, ())` into `(dyn Span<T> + 'static)` + | +LL | (T::from(from), ()).into() + | +++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs new file mode 100644 index 00000000000..2e0179fb164 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs @@ -0,0 +1,17 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +trait Empty<T> {} + +impl<T> Default for dyn Empty<T> +where + Self: Sized, +{ + fn default() -> Self { + () + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr new file mode 100644 index 00000000000..5f00ced09b8 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs:12:9 + | +LL | fn default() -> Self { + | ---- expected `(dyn Empty<T> + 'static)` because of return type +LL | () + | ^^ expected `dyn Empty`, found `()` + | + = note: expected trait object `(dyn Empty<T> + 'static)` + found unit type `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs new file mode 100644 index 00000000000..d8bc2a4321e --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs @@ -0,0 +1,18 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +#![feature(trivial_bounds)] +trait Empty {} + +impl Default for dyn Empty +where + Self: Sized, +{ + fn default() -> Self { + () + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr new file mode 100644 index 00000000000..872b7f5cee1 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs:13:9 + | +LL | fn default() -> Self { + | ---- expected `(dyn Empty + 'static)` because of return type +LL | () + | ^^ expected `dyn Empty`, found `()` + | + = note: expected trait object `(dyn Empty + 'static)` + found unit type `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs new file mode 100644 index 00000000000..c5ee46024f9 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs @@ -0,0 +1,41 @@ +// ICE Failed to normalize closure with TAIT +// issue: rust-lang/rust#109020 +//@ check-pass + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + +type WithEmplacableForFn<'a> = impl EmplacableFn + 'a; + +fn with_emplacable_for<'a, F, R>(mut f: F) -> R +where + F: for<'b> FnMut(Emplacable<WithEmplacableForFn<'b>>) -> R, +{ + fn with_emplacable_for_inner<'a, R>( + _: &'a (), + _: &mut dyn FnMut(Emplacable<WithEmplacableForFn<'a>>) -> R, + ) -> R { + fn _constrain(_: &mut ()) -> WithEmplacableForFn<'_> { + () + } + loop {} + } + + with_emplacable_for_inner(&(), &mut f) +} + +trait EmplacableFn {} + +impl EmplacableFn for () {} + +struct Emplacable<F> +where + F: EmplacableFn, +{ + phantom: PhantomData<F>, +} + +fn main() { + with_emplacable_for(|_| {}); +} |
