diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 2ec14b2f018c3..8877463ebda7a 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1508,12 +1508,14 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id // E.g: `struct Foo;`. Here, we should // eagerly error but we don't as we have `ConstKind::Unevaluated(.., [N, M])`. if !default.has_param() { - wfcx.register_wf_obligation( - tcx.def_span(param.def_id), - matches!(param.kind, GenericParamDefKind::Type { .. }) - .then(|| WellFormedLoc::Ty(param.def_id.expect_local())), - default.as_term().unwrap(), - ); + let span = tcx.def_span(param.def_id); + let wf_loc = matches!(param.kind, GenericParamDefKind::Type { .. }) + .then(|| WellFormedLoc::Ty(param.def_id.expect_local())); + // We manually normalize the default to detect diverging or ambiguous aliases. + // This is not necessary with the new solver as it adds a requirement that + // aliases can be normalized when proving the `WellFormed` goal itself. + let _ = wfcx.normalize(span, wf_loc, default); + wfcx.register_wf_obligation(span, wf_loc, default.as_term().unwrap()); } else { // If we've got a generic const parameter we still want to check its // type is correct in case both it and the param type are fully concrete. 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..1bd529062f6bf 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,17 @@ 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::InherentConst + | ty::AliasTermKind::OpaqueTy + | ty::AliasTermKind::FreeTy + | ty::AliasTermKind::FreeConst + | 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 08d3b92e9b5ef..088511c2496c3 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -510,8 +510,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>) { @@ -772,13 +770,35 @@ 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.into()); - return; // Subtree handled by compute_inherent_projection. + ty::Alias(kind, data) => { + // The new solver require aliases to normalize successfully. + // Adding this `ProjectionPredicate` makes sure that ambiguous or + // overflowing aliases cause an error in wf-check. + if self.infcx.next_trait_solver() && !data.has_escaping_bound_vars() { + let code = ObligationCauseCode::Misc; + let cause = self.cause(code); + let inf = self.infcx.next_ty_var(cause.span); + 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.into()), + } } 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..5d1c18e07fb3a --- /dev/null +++ b/tests/ui/associated-inherent-types/normalization-overflow.next.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving `T::This normalizes-to _` + --> $DIR/normalization-overflow.rs:12:17 + | +LL | type This = Self::This; + | ^^^^^^^^^^ types differ + +error[E0271]: type mismatch resolving `T::This normalizes-to _` + --> $DIR/normalization-overflow.rs:12:17 + | +LL | type This = Self::This; + | ^^^^^^^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors + +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 080c328464153..ee67aba1a7670 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr @@ -11,7 +11,7 @@ LL | fn build2(x: T) -> impl Sized { | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type - --> $DIR/recursive-in-exhaustiveness.rs:39:23 + --> $DIR/recursive-in-exhaustiveness.rs:40:23 | LL | fn build3(x: T) -> impl Sized { | ^^^^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index a3609b93cb3a8..c4eb43bfc42a6 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:30: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:30: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:41:17 + --> $DIR/recursive-in-exhaustiveness.rs:42:17 | 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 + | +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:41:16 + --> $DIR/recursive-in-exhaustiveness.rs:42: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:41:16 + --> $DIR/recursive-in-exhaustiveness.rs:42: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:41:17 + --> $DIR/recursive-in-exhaustiveness.rs:42: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:41:16 + --> $DIR/recursive-in-exhaustiveness.rs:42:16 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^^^^ types differ error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:41:17 + --> $DIR/recursive-in-exhaustiveness.rs:42: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 fa8fa0e81743b..3dc8152627f88 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs @@ -31,6 +31,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,)> @@ -43,6 +44,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..c64799c195f44 --- /dev/null +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.next_feature.stderr @@ -0,0 +1,39 @@ +error[E0271]: type mismatch resolving `X3 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + | +LL | type X1 = X2; + | ^^ types differ + +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 `X1 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:14:11 + | +LL | type X2 = X3; + | ^^ 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 `X2 normalizes-to _` + --> $DIR/infinite-type-alias-mutual-recursion.rs:18:11 + | +LL | type X3 = X1; + | ^^ 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 6 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..e54ca09fa1278 --- /dev/null +++ b/tests/ui/infinite/struct-field-with-diverging-assoc-type.next.stderr @@ -0,0 +1,17 @@ +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[E0271]: type mismatch resolving `::Diverges normalizes-to _` + --> $DIR/struct-field-with-diverging-assoc-type.rs:14:12 + | +LL | field: Box<::Diverges>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors + +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/intrinsics/panic-uninitialized-zeroed.stderr b/tests/ui/intrinsics/panic-uninitialized-zeroed.stderr new file mode 100644 index 0000000000000..fc8fe59b58005 --- /dev/null +++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `panic_uninitialized_zeroed` + | + = note: consider adding a `main` function to `$DIR/panic-uninitialized-zeroed.rs` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0601`. 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 e94f29de44f0f..1bb388b7e5ec4 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr @@ -4,6 +4,14 @@ error[E0271]: type mismatch resolving `Loop normalizes-to _` LL | type Loop = Loop; | ^^^^ types differ +error[E0271]: type mismatch resolving `Loop normalizes-to _` + --> $DIR/inherent-impls-overflow.rs:8:13 + | +LL | type Loop = Loop; + | ^^^^ types differ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0271]: type mismatch resolving `Loop normalizes-to _` --> $DIR/inherent-impls-overflow.rs:12:1 | @@ -24,6 +32,14 @@ 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[E0275]: overflow evaluating the requirement `Poly1<(T,)> well-formed` + --> $DIR/inherent-impls-overflow.rs:17: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:17:24 | @@ -43,6 +59,14 @@ 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[E0275]: overflow evaluating the requirement `Poly0<(T,)> well-formed` + --> $DIR/inherent-impls-overflow.rs:21: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:21:24 | @@ -62,7 +86,7 @@ LL | impl Poly0<()> {} | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) -error[E0275]: overflow evaluating the requirement `Poly0<()> == _` +error[E0275]: overflow evaluating the requirement `Poly0<()> well-formed` --> $DIR/inherent-impls-overflow.rs:26:6 | LL | impl Poly0<()> {} @@ -70,7 +94,7 @@ 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 9 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0271, E0275. For more information about an error, try `rustc --explain E0271`. 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/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index 45fa33dff52f6..3c2eb0ce70b07 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -27,10 +27,10 @@ LL | trait ToUnit<'a> { WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. } error[E0277]: the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied - --> $DIR/issue-118950-root-region.rs:19:9 + --> $DIR/issue-118950-root-region.rs:19:28 | LL | impl Overlap fn(Assoc<'a, T>)> for T where Missing: Overlap {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `*const T` + | ^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `*const T` | help: this trait has no implementations, consider adding one --> $DIR/issue-118950-root-region.rs:8:1 diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr index f5fd9ce9864ce..79d0bb797f7cd 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr +++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr @@ -4,6 +4,12 @@ error[E0275]: overflow evaluating the requirement `::Assoc: Trait` LL | ::Assoc: Trait, | ^^^^^ -error: aborting due to 1 previous error +error[E0275]: overflow evaluating the requirement `::Assoc well-formed` + --> $DIR/normalize-param-env-4.rs:19:26 + | +LL | ::Assoc: Trait, + | ^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0275`. 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!(); }