diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index bbf36fef1ddbe..dcc6ab1a08b5d 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -393,7 +393,7 @@ fn compare_method_predicate_entailment<'tcx>( for obligation in obligations { debug!(?obligation); match obligation.predicate.kind().skip_binder() { - // We need to register Projection oblgiations too, because we may end up with + // We need to register Projection obligations too, because we may end up with // an implied `X::Item: 'a`, which gets desugared into `X::Item = ?0`, `?0: 'a`. // If we only register the region outlives obligation, this leads to an unconstrained var. // See `implied_bounds_entailment_alias_var.rs` test. diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 309221f9a127a..938a546395a58 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -381,8 +381,6 @@ fn check_predicates<'tcx>( let obligations = wf::obligations(infcx, tcx.param_env(impl1_def_id), impl1_def_id, 0, term, span) .unwrap(); - - assert!(!obligations.has_infer()); impl2_predicates .extend(traits::elaborate(tcx, obligations).map(|obligation| obligation.predicate)) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs index e068e60790277..fe8ecc0bfe893 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs @@ -39,7 +39,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.type_matches_expected_vid(expected_vid, data.self_ty()) } ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => { - self.type_matches_expected_vid(expected_vid, data.projection_term.self_ty()) + match data.projection_term.kind(self.tcx) { + ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst => { + self.type_matches_expected_vid(expected_vid, data.projection_term.self_ty()) + } + ty::AliasTermKind::InherentTy + | ty::AliasTermKind::OpaqueTy + | ty::AliasTermKind::FreeTy + | ty::AliasTermKind::UnevaluatedConst => false, + } } ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..)) | ty::PredicateKind::Subtype(..) diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 2e32cda7602e4..cd308ce1d6348 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -509,8 +509,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { let obligations = self.nominal_obligations(data.def_id, args); self.out.extend(obligations); } - - data.args.visit_with(self); } fn add_wf_preds_for_projection_args(&mut self, args: GenericArgsRef<'tcx>) { @@ -771,13 +769,34 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { // Simple cases that are WF if their type args are WF. } - ty::Alias(ty::Projection | ty::Opaque | ty::Free, data) => { - let obligations = self.nominal_obligations(data.def_id, data.args); - self.out.extend(obligations); - } - ty::Alias(ty::Inherent, data) => { - self.add_wf_preds_for_inherent_projection(data); - return; // Subtree handled by compute_inherent_projection. + ty::Alias(kind, data) => { + let code = ObligationCauseCode::Misc; + let cause = self.cause(code); + let inf = self.infcx.next_ty_var(rustc_span::DUMMY_SP); + let projection_goal_supported = + matches!(kind, ty::Projection) || self.infcx.next_trait_solver(); + if projection_goal_supported && !data.has_escaping_bound_vars() { + let obligation: traits::PredicateObligation<'tcx> = + traits::Obligation::with_depth( + self.tcx(), + cause, + self.recursion_depth, + self.param_env, + ty::ProjectionPredicate { + projection_term: data.into(), + term: inf.into(), + }, + ); + self.out.push(obligation); + } + + match kind { + ty::Projection | ty::Opaque | ty::Free => { + let obligations = self.nominal_obligations(data.def_id, data.args); + self.out.extend(obligations); + } + ty::Inherent => self.add_wf_preds_for_inherent_projection(data), + } } ty::Adt(def, args) => { diff --git a/tests/crashes/102252.rs b/tests/crashes/102252.rs deleted file mode 100644 index 200782f95c861..0000000000000 --- a/tests/crashes/102252.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #102252 - -#![feature(min_specialization, rustc_attrs)] - -#[rustc_specialization_trait] -pub trait Trait {} - -struct Struct -where - Self: Iterator::Item>, {} - -impl Trait for Struct {} - -fn main() {} diff --git a/tests/crashes/126268.rs b/tests/crashes/126268.rs deleted file mode 100644 index 82e52fa115dc9..0000000000000 --- a/tests/crashes/126268.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #126268 -#![feature(min_specialization)] - -trait Trait {} - -impl Trait for T {} - -trait Data { - type Elem; -} - -struct DatasetIter<'a, R: Data> { - data: &'a R::Elem, -} - -pub struct ArrayBase {} - -impl<'a> Trait for DatasetIter<'a, ArrayBase> {} diff --git a/tests/ui/associated-inherent-types/normalization-overflow.stderr b/tests/ui/associated-inherent-types/normalization-overflow.current.stderr similarity index 79% rename from tests/ui/associated-inherent-types/normalization-overflow.stderr rename to tests/ui/associated-inherent-types/normalization-overflow.current.stderr index 7f991a53c9bb7..b234e59188493 100644 --- a/tests/ui/associated-inherent-types/normalization-overflow.stderr +++ b/tests/ui/associated-inherent-types/normalization-overflow.current.stderr @@ -1,5 +1,5 @@ error: overflow evaluating associated type `T::This` - --> $DIR/normalization-overflow.rs:9:17 + --> $DIR/normalization-overflow.rs:12:17 | LL | type This = Self::This; | ^^^^^^^^^^ diff --git a/tests/ui/associated-inherent-types/normalization-overflow.next.stderr b/tests/ui/associated-inherent-types/normalization-overflow.next.stderr new file mode 100644 index 0000000000000..f38508a2328ce --- /dev/null +++ b/tests/ui/associated-inherent-types/normalization-overflow.next.stderr @@ -0,0 +1,9 @@ +error[E0271]: type mismatch resolving `T::This normalizes-to _` + --> $DIR/normalization-overflow.rs:12:17 + | +LL | type This = Self::This; + | ^^^^^^^^^^ types differ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/associated-inherent-types/normalization-overflow.rs b/tests/ui/associated-inherent-types/normalization-overflow.rs index 4228238aa7b7a..ce57ea5ca21af 100644 --- a/tests/ui/associated-inherent-types/normalization-overflow.rs +++ b/tests/ui/associated-inherent-types/normalization-overflow.rs @@ -1,3 +1,6 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) #![feature(inherent_associated_types)] #![allow(incomplete_features)] @@ -6,7 +9,9 @@ struct T; impl T { - type This = Self::This; //~ ERROR overflow evaluating associated type `T::This` + type This = Self::This; + //[current]~^ ERROR overflow evaluating associated type `T::This` + //[next]~^^ ERROR type mismatch resolving `T::This normalizes-to _` } fn main() {} diff --git a/tests/ui/auto-traits/assoc-ty.next.stderr b/tests/ui/auto-traits/assoc-ty.next.stderr index 4ce00d1747564..40130d93f2d25 100644 --- a/tests/ui/auto-traits/assoc-ty.next.stderr +++ b/tests/ui/auto-traits/assoc-ty.next.stderr @@ -35,7 +35,15 @@ LL | let _: <() as Trait>::Output = (); | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 4 previous errors +error[E0271]: type mismatch resolving `<() as Trait>::Output normalizes-to _` + --> $DIR/assoc-ty.rs:15:12 + | +LL | let _: <() as Trait>::Output = (); + | ^^^^^^^^^^^^^^^^^^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 5 previous errors Some errors have detailed explanations: E0271, E0380, E0658. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/auto-traits/assoc-ty.rs b/tests/ui/auto-traits/assoc-ty.rs index efbfead9cd037..8932465660e5d 100644 --- a/tests/ui/auto-traits/assoc-ty.rs +++ b/tests/ui/auto-traits/assoc-ty.rs @@ -16,4 +16,5 @@ fn main() { //[current]~^ ERROR mismatched types //[next]~^^ ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` //[next]~| ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` + //[next]~| ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _` } diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr index a95670ced8678..1cfc2a6d94495 100644 --- a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr @@ -18,11 +18,6 @@ help: this trait has no implementations, consider adding one | LL | trait Foo {} | ^^^^^^^^^ -note: required by a bound in `A` - --> $DIR/alias-bounds-when-not-wf.rs:8:11 - | -LL | type A = T; - | ^^^ required by this bound in `A` error[E0277]: the trait bound `usize: Foo` is not satisfied --> $DIR/alias-bounds-when-not-wf.rs:16:10 diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr index 42dbc7c91607f..a8515b2f83aee 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr @@ -31,7 +31,7 @@ LL | (build2(x),) | ------------ returning here with type `(impl Sized,)` warning: function cannot return without recursing - --> $DIR/recursive-in-exhaustiveness.rs:40:1 + --> $DIR/recursive-in-exhaustiveness.rs:41:1 | LL | fn build3(x: T) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -42,7 +42,7 @@ LL | let (x,) = (build3((x,)),); = help: a `loop` may express intention better if this is on purpose error[E0792]: expected generic type parameter, found `(T,)` - --> $DIR/recursive-in-exhaustiveness.rs:49:5 + --> $DIR/recursive-in-exhaustiveness.rs:51:5 | LL | fn build3(x: T) -> impl Sized { | - this generic parameter must be used with a generic type parameter diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index 4c3d5aa8fb8f0..f026c86e2859d 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr @@ -10,6 +10,14 @@ error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` LL | (build2(x),) | ^^^^^^^^^ types differ +error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` + --> $DIR/recursive-in-exhaustiveness.rs:31:6 + | +LL | (build2(x),) + | ^^^^^^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` --> $DIR/recursive-in-exhaustiveness.rs:31:5 | @@ -26,13 +34,21 @@ LL | (build2(x),) = note: tuples must have a statically known size to be initialized error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:43:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ +error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` + --> $DIR/recursive-in-exhaustiveness.rs:43:17 + | +LL | let (x,) = (build3((x,)),); + | ^^^^^^^^^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0277]: the size for values of type `(impl Sized,)` cannot be known at compilation time - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:43:16 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -41,7 +57,7 @@ LL | let (x,) = (build3((x,)),); = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:43:16 | LL | fn build3(x: T) -> impl Sized { | ---------- the found opaque type @@ -53,7 +69,7 @@ LL | let (x,) = (build3((x,)),); found tuple `(impl Sized,)` error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:43:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ @@ -61,20 +77,20 @@ LL | let (x,) = (build3((x,)),); = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:43:16 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^^^^ types differ error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:43:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 10 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0271, E0277, E0284, E0308. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs index 58944533686cc..54a2232677ec7 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs @@ -32,6 +32,7 @@ fn build2(x: T) -> impl Sized { //[next]~^ ERROR type mismatch resolving //[next]~| ERROR type mismatch resolving //[next]~| ERROR the size for values of type + //[next]~| ERROR type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` } // Opaque = Opaque<(T,)> @@ -44,6 +45,7 @@ fn build3(x: T) -> impl Sized { //[next]~| ERROR type mismatch resolving //[next]~| ERROR type mismatch resolving //[next]~| ERROR type mismatch resolving + //[next]~| ERROR type mismatch resolving //[next]~| ERROR the size for values of type //[next]~| ERROR mismatched types build3(x) diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_feature.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_feature.stderr new file mode 100644 index 0000000000000..21fd740ef60ec --- /dev/null +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_feature.stderr @@ -0,0 +1,27 @@ +error[E0275]: overflow normalizing the type alias `X2` + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + | +LL | type X1 = X2; + | ^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `X3` + --> $DIR/infinite-type-alias-mutual-recursion.rs:14:11 + | +LL | type X2 = X3; + | ^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error[E0275]: overflow normalizing the type alias `X1` + --> $DIR/infinite-type-alias-mutual-recursion.rs:18:11 + | +LL | type X3 = X1; + | ^^ + | + = note: in case this is a recursive type alias, consider using a struct, enum, or union instead + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_gated.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_gated.stderr new file mode 100644 index 0000000000000..31062e8501d68 --- /dev/null +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.current_gated.stderr @@ -0,0 +1,30 @@ +error[E0391]: cycle detected when expanding type alias `X1` + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + | +LL | type X1 = X2; + | ^^ + | +note: ...which requires expanding type alias `X2`... + --> $DIR/infinite-type-alias-mutual-recursion.rs:14:11 + | +LL | type X2 = X3; + | ^^ +note: ...which requires expanding type alias `X3`... + --> $DIR/infinite-type-alias-mutual-recursion.rs:18:11 + | +LL | type X3 = X1; + | ^^ + = note: ...which again requires expanding type alias `X1`, completing the cycle + = note: type aliases cannot be recursive + = help: consider using a struct, enum, or union instead to break the cycle + = help: see for more information +note: cycle used when checking that `X1` is well-formed + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:1 + | +LL | type X1 = X2; + | ^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_feature.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_feature.stderr new file mode 100644 index 0000000000000..7a150cb510ee3 --- /dev/null +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_feature.stderr @@ -0,0 +1,21 @@ +error[E0271]: type mismatch resolving `X2 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + | +LL | type X1 = X2; + | ^^ types differ + +error[E0271]: type mismatch resolving `X3 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:14:11 + | +LL | type X2 = X3; + | ^^ types differ + +error[E0271]: type mismatch resolving `X1 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:18:11 + | +LL | type X3 = X1; + | ^^ types differ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_gated.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_gated.stderr new file mode 100644 index 0000000000000..31062e8501d68 --- /dev/null +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_gated.stderr @@ -0,0 +1,30 @@ +error[E0391]: cycle detected when expanding type alias `X1` + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + | +LL | type X1 = X2; + | ^^ + | +note: ...which requires expanding type alias `X2`... + --> $DIR/infinite-type-alias-mutual-recursion.rs:14:11 + | +LL | type X2 = X3; + | ^^ +note: ...which requires expanding type alias `X3`... + --> $DIR/infinite-type-alias-mutual-recursion.rs:18:11 + | +LL | type X3 = X1; + | ^^ + = note: ...which again requires expanding type alias `X1`, completing the cycle + = note: type aliases cannot be recursive + = help: consider using a struct, enum, or union instead to break the cycle + = help: see for more information +note: cycle used when checking that `X1` is well-formed + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:1 + | +LL | type X1 = X2; + | ^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs b/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs index cf9ea0db4cbee..e90d14eb6f5dc 100644 --- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs @@ -1,14 +1,22 @@ -//@ revisions: feature gated +//@ revisions: current_feature next_feature current_gated next_gated +//@[next_feature] compile-flags: -Znext-solver +//@[next_gated] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) -#![cfg_attr(feature, feature(lazy_type_alias))] +#![cfg_attr(any(current_feature, next_feature), feature(lazy_type_alias))] #![allow(incomplete_features)] type X1 = X2; -//[gated]~^ ERROR cycle detected when expanding type alias `X1` -//[feature]~^^ ERROR: overflow normalizing the type alias `X2` +//[current_gated]~^ ERROR cycle detected when expanding type alias `X1` +//[next_gated]~^^ ERROR cycle detected when expanding type alias `X1` +//[current_feature]~^^^ ERROR: overflow normalizing the type alias `X2` +//[next_feature]~^^^^ ERROR: type mismatch resolving `X2 normalizes-to _` type X2 = X3; -//[feature]~^ ERROR: overflow normalizing the type alias `X3` +//[current_feature]~^ ERROR: overflow normalizing the type alias `X3` +//[next_feature]~^^ ERROR: type mismatch resolving `X3 normalizes-to _` + type X3 = X1; -//[feature]~^ ERROR: overflow normalizing the type alias `X1` +//[current_feature]~^ ERROR: overflow normalizing the type alias `X1` +//[next_feature]~^^ ERROR: type mismatch resolving `X1 normalizes-to _` fn main() {} diff --git a/tests/ui/infinite/struct-field-with-diverging-assoc-type.current.stderr b/tests/ui/infinite/struct-field-with-diverging-assoc-type.current.stderr new file mode 100644 index 0000000000000..f0f0e6f89f403 --- /dev/null +++ b/tests/ui/infinite/struct-field-with-diverging-assoc-type.current.stderr @@ -0,0 +1,9 @@ +error[E0275]: overflow evaluating the requirement `::Diverges == _` + --> $DIR/struct-field-with-diverging-assoc-type.rs:14:12 + | +LL | field: Box<::Diverges>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/infinite/struct-field-with-diverging-assoc-type.next.stderr b/tests/ui/infinite/struct-field-with-diverging-assoc-type.next.stderr new file mode 100644 index 0000000000000..d2ed3216dbfc3 --- /dev/null +++ b/tests/ui/infinite/struct-field-with-diverging-assoc-type.next.stderr @@ -0,0 +1,9 @@ +error[E0271]: type mismatch resolving `::Diverges normalizes-to _` + --> $DIR/struct-field-with-diverging-assoc-type.rs:14:12 + | +LL | field: Box<::Diverges>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/infinite/struct-field-with-diverging-assoc-type.rs b/tests/ui/infinite/struct-field-with-diverging-assoc-type.rs new file mode 100644 index 0000000000000..d15f8fcd7cd09 --- /dev/null +++ b/tests/ui/infinite/struct-field-with-diverging-assoc-type.rs @@ -0,0 +1,19 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +trait Trait { + type Diverges; +} + +impl Trait for T { + type Diverges = D::Diverges; +} + +struct Foo { + field: Box<::Diverges>, + //[current]~^ ERROR overflow evaluating the requirement + //[next]~^^ ERROR type mismatch resolving +} + +fn main() {} diff --git a/tests/ui/infinite/type-param-default-with-diverging-assoc-type.current.stderr b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.current.stderr new file mode 100644 index 0000000000000..8a07ea0981616 --- /dev/null +++ b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.current.stderr @@ -0,0 +1,9 @@ +error[E0275]: overflow evaluating the requirement `::Diverges == _` + --> $DIR/type-param-default-with-diverging-assoc-type.rs:13:12 + | +LL | struct Bar::Diverges>(Box); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/infinite/type-param-default-with-diverging-assoc-type.next.stderr b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.next.stderr new file mode 100644 index 0000000000000..f2bb7dce56f93 --- /dev/null +++ b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.next.stderr @@ -0,0 +1,9 @@ +error[E0271]: type mismatch resolving `::Diverges normalizes-to _` + --> $DIR/type-param-default-with-diverging-assoc-type.rs:13:12 + | +LL | struct Bar::Diverges>(Box); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/infinite/type-param-default-with-diverging-assoc-type.rs b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.rs new file mode 100644 index 0000000000000..0c6032d0384e4 --- /dev/null +++ b/tests/ui/infinite/type-param-default-with-diverging-assoc-type.rs @@ -0,0 +1,17 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +trait Trait { + type Diverges; +} + +impl Trait for T { + type Diverges = D::Diverges; +} + +struct Bar::Diverges>(Box); +//[current]~^ ERROR overflow evaluating the requirement +//[next]~^^ ERROR type mismatch resolving + +fn main() {} diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr index 05f5449dbc8be..a5c62bc93b04c 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr @@ -7,7 +7,7 @@ LL | type Loop = Loop; = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Loop` - --> $DIR/inherent-impls-overflow.rs:10:1 + --> $DIR/inherent-impls-overflow.rs:12:1 | LL | impl Loop {} | ^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | impl Loop {} = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:14:17 + --> $DIR/inherent-impls-overflow.rs:16:17 | LL | type Poly0 = Poly1<(T,)>; | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | type Poly0 = Poly1<(T,)>; = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:17:17 + --> $DIR/inherent-impls-overflow.rs:20:17 | LL | type Poly1 = Poly0<(T,)>; | ^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | type Poly1 = Poly0<(T,)>; = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:21:1 + --> $DIR/inherent-impls-overflow.rs:25:1 | LL | impl Poly0<()> {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr index 4f1d339bc999d..4a2865a8a39a9 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr @@ -1,11 +1,25 @@ error[E0271]: type mismatch resolving `Loop normalizes-to _` - --> $DIR/inherent-impls-overflow.rs:10:6 + --> $DIR/inherent-impls-overflow.rs:8:13 + | +LL | type Loop = Loop; + | ^^^^ types differ + +error[E0271]: type mismatch resolving `Loop normalizes-to _` + --> $DIR/inherent-impls-overflow.rs:12:6 | LL | impl Loop {} | ^^^^ types differ +error[E0275]: overflow evaluating the requirement `Poly1<(T,)> well-formed` + --> $DIR/inherent-impls-overflow.rs:16:17 + | +LL | type Poly0 = Poly1<(T,)>; + | ^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) + error: type parameter `T` is only used recursively - --> $DIR/inherent-impls-overflow.rs:14:24 + --> $DIR/inherent-impls-overflow.rs:16:24 | LL | type Poly0 = Poly1<(T,)>; | - ^ @@ -15,8 +29,16 @@ LL | type Poly0 = Poly1<(T,)>; = help: consider removing `T` or referring to it in the body of the type alias = note: all type parameters must be used in a non-recursive way in order to constrain their variance +error[E0275]: overflow evaluating the requirement `Poly0<(T,)> well-formed` + --> $DIR/inherent-impls-overflow.rs:20:17 + | +LL | type Poly1 = Poly0<(T,)>; + | ^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) + error: type parameter `T` is only used recursively - --> $DIR/inherent-impls-overflow.rs:17:24 + --> $DIR/inherent-impls-overflow.rs:20:24 | LL | type Poly1 = Poly0<(T,)>; | - ^ @@ -26,15 +48,15 @@ LL | type Poly1 = Poly0<(T,)>; = help: consider removing `T` or referring to it in the body of the type alias = note: all type parameters must be used in a non-recursive way in order to constrain their variance -error[E0275]: overflow evaluating the requirement `Poly0<()> == _` - --> $DIR/inherent-impls-overflow.rs:21:6 +error[E0275]: overflow evaluating the requirement `Poly0<()> well-formed` + --> $DIR/inherent-impls-overflow.rs:25:6 | LL | impl Poly0<()> {} | ^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) -error: aborting due to 4 previous errors +error: aborting due to 7 previous errors Some errors have detailed explanations: E0271, E0275. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs index 0d5ec7d153073..80af530aff594 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs @@ -5,7 +5,9 @@ #![feature(lazy_type_alias)] #![allow(incomplete_features)] -type Loop = Loop; //[current]~ ERROR overflow normalizing the type alias `Loop` +type Loop = Loop; +//[current]~^ ERROR overflow normalizing the type alias `Loop` +//[next]~^^ ERROR type mismatch resolving `Loop normalizes-to _` impl Loop {} //[current]~^ ERROR overflow normalizing the type alias `Loop` @@ -14,12 +16,14 @@ impl Loop {} type Poly0 = Poly1<(T,)>; //[current]~^ ERROR overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` //[next]~^^ ERROR type parameter `T` is only used recursively +//[next]~| ERROR overflow evaluating the requirement `Poly1<(T,)> well-formed` type Poly1 = Poly0<(T,)>; //[current]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` //[next]~^^ ERROR type parameter `T` is only used recursively +//[next]~| ERROR overflow evaluating the requirement `Poly0<(T,)> well-formed` impl Poly0<()> {} //[current]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` -//[next]~^^ ERROR overflow evaluating the requirement `Poly0<()> == _` +//[next]~^^ ERROR overflow evaluating the requirement `Poly0<()> well-formed` fn main() {} diff --git a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs index 1b2c359afc90b..d7eee3c804c43 100644 --- a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs +++ b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs @@ -31,4 +31,5 @@ fn main() { //~^ ERROR implementation of `Y` is not general enough //~| ERROR implementation of `Y` is not general enough //~| ERROR implementation of `Y` is not general enough + //~| ERROR implementation of `Y` is not general enough } diff --git a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr index 804071a3e6f77..565fb33727557 100644 --- a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr +++ b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr @@ -27,5 +27,15 @@ LL | let _x = ::make_f(); = note: ...but `Y` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error: implementation of `Y` is not general enough + --> $DIR/impl-fn-ignore-binder-via-bottom.rs:30:14 + | +LL | let _x = ::make_f(); + | ^^^^^^^^^^^^^^^^^^^ implementation of `Y` is not general enough + | + = note: `Y` would have to be implemented for the type `for<'a> fn(&'a ())` + = note: ...but `Y` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-102252.rs b/tests/ui/specialization/fuzzed/fuzzing-ice-102252.rs new file mode 100644 index 0000000000000..db43b2aef8f18 --- /dev/null +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-102252.rs @@ -0,0 +1,20 @@ +// This test previous triggered an assertion that there are no inference variables +// returned by `wf::obligations`. Overflow when normalizing +// `Self: Iterator::Item>` resulted in overflow which then +// caused us to return an infer var. +// +// This assert has now been removed. +#![feature(min_specialization, rustc_attrs)] + +#[rustc_specialization_trait] +pub trait Trait {} + +struct Struct +//~^ ERROR overflow evaluating the requirement `::Item == _` +where + Self: Iterator::Item>, {} + +impl Trait for Struct {} +//~^ ERROR `Struct` is not an iterator + +fn main() {} diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-102252.stderr b/tests/ui/specialization/fuzzed/fuzzing-ice-102252.stderr new file mode 100644 index 0000000000000..3bdd4873c4eee --- /dev/null +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-102252.stderr @@ -0,0 +1,26 @@ +error[E0275]: overflow evaluating the requirement `::Item == _` + --> $DIR/fuzzing-ice-102252.rs:12:1 + | +LL | struct Struct + | ^^^^^^^^^^^^^ + +error[E0277]: `Struct` is not an iterator + --> $DIR/fuzzing-ice-102252.rs:17:16 + | +LL | impl Trait for Struct {} + | ^^^^^^ `Struct` is not an iterator + | + = help: the trait `Iterator` is not implemented for `Struct` +note: required by a bound in `Struct` + --> $DIR/fuzzing-ice-102252.rs:15:11 + | +LL | struct Struct + | ------ required by a bound in this struct +... +LL | Self: Iterator::Item>, {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Struct` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0275, E0277. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-126268.rs b/tests/ui/specialization/fuzzed/fuzzing-ice-126268.rs new file mode 100644 index 0000000000000..86a0b8a77c164 --- /dev/null +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-126268.rs @@ -0,0 +1,25 @@ +// This test previous triggered an assertion that there are no inference variables +// returned by `wf::obligations`. We ended up with an infer var as we failed to +// normalize `R::Elem`. +// +// This assert has now been removed. +#![feature(min_specialization)] + +trait Trait {} + +impl Trait for T {} + +trait Data { + type Elem; +} + +struct DatasetIter<'a, R: Data> { + data: &'a R::Elem, +} + +pub struct ArrayBase {} + +impl<'a> Trait for DatasetIter<'a, ArrayBase> {} +//~^ ERROR specialization impl does not specialize any associated items + +fn main() {} diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-126268.stderr b/tests/ui/specialization/fuzzed/fuzzing-ice-126268.stderr new file mode 100644 index 0000000000000..b354a63d91920 --- /dev/null +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-126268.stderr @@ -0,0 +1,14 @@ +error: specialization impl does not specialize any associated items + --> $DIR/fuzzing-ice-126268.rs:22:1 + | +LL | impl<'a> Trait for DatasetIter<'a, ArrayBase> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl is a specialization of this impl + --> $DIR/fuzzing-ice-126268.rs:10:1 + | +LL | impl Trait for T {} + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr index bf8d3c40cf653..54281b6661c2b 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr @@ -10,18 +10,6 @@ note: required because it appears within the type `Tail` | LL | struct Tail([()]); | ^^^^ -note: required by a bound in `Bad::Assert` - --> $DIR/trivial-unsized-projection-2.rs:14:15 - | -LL | type Assert - | ------ required by a bound in this associated type -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bad::Assert` -help: consider relaxing the implicit `Sized` restriction - | -LL | type Assert: ?Sized - | ++++++++ error[E0277]: the size for values of type `[()]` cannot be known at compilation time --> $DIR/trivial-unsized-projection-2.rs:22:12 @@ -35,19 +23,7 @@ note: required because it appears within the type `Tail` | LL | struct Tail([()]); | ^^^^ -note: required by a bound in `Bad::Assert` - --> $DIR/trivial-unsized-projection-2.rs:14:15 - | -LL | type Assert - | ------ required by a bound in this associated type -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bad::Assert` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider relaxing the implicit `Sized` restriction - | -LL | type Assert: ?Sized - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/traits/trivial-unsized-projection.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection.bad_new.stderr index 4aea63329b360..6d06ffbd52efd 100644 --- a/tests/ui/traits/trivial-unsized-projection.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection.bad_new.stderr @@ -5,18 +5,6 @@ LL | const FOO: <[()] as Bad>::Assert = todo!(); | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[()]` -note: required by a bound in `Bad::Assert` - --> $DIR/trivial-unsized-projection.rs:14:15 - | -LL | type Assert - | ------ required by a bound in this associated type -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bad::Assert` -help: consider relaxing the implicit `Sized` restriction - | -LL | type Assert: ?Sized - | ++++++++ error[E0277]: the size for values of type `[()]` cannot be known at compilation time --> $DIR/trivial-unsized-projection.rs:20:12 @@ -25,19 +13,7 @@ LL | const FOO: <[()] as Bad>::Assert = todo!(); | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[()]` -note: required by a bound in `Bad::Assert` - --> $DIR/trivial-unsized-projection.rs:14:15 - | -LL | type Assert - | ------ required by a bound in this associated type -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bad::Assert` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider relaxing the implicit `Sized` restriction - | -LL | type Assert: ?Sized - | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr index 9e83de5375fd7..bea1d6c90f837 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr @@ -7,7 +7,7 @@ LL | impl Trait for Out { LL | impl Trait<(), In> for Out { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation -error[E0284]: type annotations needed: cannot satisfy `Bar == _` +error[E0284]: type annotations needed --> $DIR/issue-84660-unsoundness.rs:24:37 | LL | fn convert(_i: In) -> Self::Out { @@ -16,7 +16,9 @@ LL | | LL | | LL | | unreachable!(); LL | | } - | |_____^ cannot satisfy `Bar == _` + | |_____^ cannot infer type + | + = note: cannot satisfy `Bar == _` error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs index 7a540d2a57495..a385138b29502 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs @@ -22,7 +22,7 @@ impl Trait for Out { type Out = Out; #[define_opaque(Bar)] fn convert(_i: In) -> Self::Out { - //[next]~^ ERROR: type annotations needed: cannot satisfy `Bar == _` + //[next]~^ ERROR: type annotations needed //[current]~^^ ERROR: item does not constrain `Bar::{opaque#0}` unreachable!(); }