From 16a95b53d84b12dcf9ab6197f6d917ac7d1dee99 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 14 Feb 2025 00:26:30 +0000 Subject: [PATCH] Instantiate predicate binder without recanonicalizing goal in new solver --- .../src/fn_ctxt/inspect_obligations.rs | 17 +-- .../src/solve/eval_ctxt/mod.rs | 102 ++++++++---------- .../src/solve/fulfill/derive_errors.rs | 5 - .../src/traits/coherence.rs | 7 +- compiler/rustc_type_ir/src/solve/mod.rs | 2 - ...overlap-unnormalizable-projection-1.stderr | 2 +- ...didate-from-env-universe-err-1.next.stderr | 23 ---- .../candidate-from-env-universe-err-1.rs | 3 +- ...didate-from-env-universe-err-2.next.stderr | 15 --- .../candidate-from-env-universe-err-2.rs | 3 +- ...om-env-universe-err-project.current.stderr | 6 +- ...-from-env-universe-err-project.next.stderr | 35 +----- ...candidate-from-env-universe-err-project.rs | 6 +- .../leak-check-in-selection-2.next.stderr | 23 ---- .../leak-check/leak-check-in-selection-2.rs | 3 +- .../leak-check-in-selection-3.next.stderr | 27 +---- .../leak-check-in-selection-3.old.stderr | 6 +- .../leak-check/leak-check-in-selection-3.rs | 1 - ...eck-in-selection-6-ambig-unify.next.stderr | 22 ---- ...heck-in-selection-6-ambig-unify.old.stderr | 6 +- .../leak-check-in-selection-6-ambig-unify.rs | 3 +- ...rg-type-mismatch-issue-45727.current.fixed | 1 + ...-arg-type-mismatch-issue-45727.next.stderr | 13 ++- .../closure-arg-type-mismatch-issue-45727.rs | 1 + 24 files changed, 91 insertions(+), 241 deletions(-) delete mode 100644 tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.next.stderr delete mode 100644 tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.next.stderr delete mode 100644 tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.next.stderr delete mode 100644 tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.next.stderr 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 dc10b53fd8390..eb5fe3a86e4c5 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs @@ -7,7 +7,6 @@ use rustc_span::Span; use rustc_trait_selection::solve::inspect::{ InspectConfig, InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor, }; -use rustc_type_ir::solve::GoalSource; use tracing::{debug, instrument, trace}; use crate::FnCtxt; @@ -120,21 +119,7 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for NestedObligationsForSelfTy<'a, 'tcx> { fn visit_goal(&mut self, inspect_goal: &InspectGoal<'_, 'tcx>) { let tcx = self.fcx.tcx; let goal = inspect_goal.goal(); - if self.fcx.predicate_has_self_ty(goal.predicate, self.self_ty) - // We do not push the instantiated forms of goals as it would cause any - // aliases referencing bound vars to go from having escaping bound vars to - // being able to be normalized to an inference variable. - // - // This is mostly just a hack as arbitrary nested goals could still contain - // such aliases while having a different `GoalSource`. Closure signature inference - // however can't really handle *every* higher ranked `Fn` goal also being present - // in the form of `?c: Fn<(>::Assoc)`. - // - // This also just better matches the behaviour of the old solver where we do not - // encounter instantiated forms of goals, only nested goals that referred to bound - // vars from instantiated goals. - && !matches!(inspect_goal.source(), GoalSource::InstantiateHigherRanked) - { + if self.fcx.predicate_has_self_ty(goal.predicate, self.self_ty) { self.obligations_for_self_ty.push(traits::Obligation::new( tcx, self.root_cause.clone(), diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index b0a34b9ce7560..7f0c581e329c4 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -448,63 +448,53 @@ where fn compute_goal(&mut self, goal: Goal) -> QueryResult { let Goal { param_env, predicate } = goal; let kind = predicate.kind(); - if let Some(kind) = kind.no_bound_vars() { - match kind { - ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => { - self.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r) - } - ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => { - self.compute_host_effect_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => { - self.compute_projection_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => { - self.compute_type_outlives_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => { - self.compute_region_outlives_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => { - self.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) }) - } - ty::PredicateKind::Subtype(predicate) => { - self.compute_subtype_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::Coerce(predicate) => { - self.compute_coerce_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::DynCompatible(trait_def_id) => { - self.compute_dyn_compatible_goal(trait_def_id) - } - ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { - self.compute_well_formed_goal(Goal { param_env, predicate: arg }) - } - ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => { - self.compute_const_evaluatable_goal(Goal { param_env, predicate: ct }) - } - ty::PredicateKind::ConstEquate(_, _) => { - panic!("ConstEquate should not be emitted when `-Znext-solver` is active") - } - ty::PredicateKind::NormalizesTo(predicate) => { - self.compute_normalizes_to_goal(Goal { param_env, predicate }) - } - ty::PredicateKind::AliasRelate(lhs, rhs, direction) => self - .compute_alias_relate_goal(Goal { - param_env, - predicate: (lhs, rhs, direction), - }), - ty::PredicateKind::Ambiguous => { - self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) - } + self.enter_forall(kind, |ecx, kind| match kind { + ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => { + ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r) } - } else { - self.enter_forall(kind, |ecx, kind| { - let goal = goal.with(ecx.cx(), ty::Binder::dummy(kind)); - ecx.add_goal(GoalSource::InstantiateHigherRanked, goal); - ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - }) - } + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => { + ecx.compute_host_effect_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => { + ecx.compute_projection_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => { + ecx.compute_type_outlives_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => { + ecx.compute_region_outlives_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => { + ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) }) + } + ty::PredicateKind::Subtype(predicate) => { + ecx.compute_subtype_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::Coerce(predicate) => { + ecx.compute_coerce_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::DynCompatible(trait_def_id) => { + ecx.compute_dyn_compatible_goal(trait_def_id) + } + ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { + ecx.compute_well_formed_goal(Goal { param_env, predicate: arg }) + } + ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => { + ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct }) + } + ty::PredicateKind::ConstEquate(_, _) => { + panic!("ConstEquate should not be emitted when `-Znext-solver` is active") + } + ty::PredicateKind::NormalizesTo(predicate) => { + ecx.compute_normalizes_to_goal(Goal { param_env, predicate }) + } + ty::PredicateKind::AliasRelate(lhs, rhs, direction) => { + ecx.compute_alias_relate_goal(Goal { param_env, predicate: (lhs, rhs, direction) }) + } + ty::PredicateKind::Ambiguous => { + ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) + } + }) } // Recursively evaluates all the goals added to this `EvalCtxt` to completion, returning diff --git a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs index 7364b4aa34380..ebdf39a75ec3d 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs @@ -209,7 +209,6 @@ impl<'tcx> BestObligation<'tcx> { nested_goal.source(), GoalSource::ImplWhereBound | GoalSource::AliasBoundConstCondition - | GoalSource::InstantiateHigherRanked | GoalSource::AliasWellFormed ) && match (self.consider_ambiguities, nested_goal.result()) { (true, Ok(Certainty::Maybe(MaybeCause::Ambiguity))) @@ -380,10 +379,6 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { )); impl_where_bound_count += 1; } - // Skip over a higher-ranked predicate. - (_, GoalSource::InstantiateHigherRanked) => { - obligation = self.obligation.clone(); - } (ChildMode::PassThrough, _) | (_, GoalSource::AliasWellFormed | GoalSource::AliasBoundConstCondition) => { obligation = make_obligation(self.obligation.cause.clone()); diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 3b40882ef572d..fe634b0bf89e9 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -660,9 +660,10 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> { // For bound predicates we simply call `infcx.enter_forall` // and then prove the resulting predicate as a nested goal. let Goal { param_env, predicate } = goal.goal(); - let trait_ref = match predicate.kind().no_bound_vars() { - Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr))) => tr.trait_ref, - Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj))) + let predicate_kind = goal.infcx().enter_forall_and_leak_universe(predicate.kind()); + let trait_ref = match predicate_kind { + ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr)) => tr.trait_ref, + ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) if matches!( infcx.tcx.def_kind(proj.projection_term.def_id), DefKind::AssocTy | DefKind::AssocConst diff --git a/compiler/rustc_type_ir/src/solve/mod.rs b/compiler/rustc_type_ir/src/solve/mod.rs index a562b751d8a9c..0f16e84ad85ee 100644 --- a/compiler/rustc_type_ir/src/solve/mod.rs +++ b/compiler/rustc_type_ir/src/solve/mod.rs @@ -72,8 +72,6 @@ pub enum GoalSource { /// /// FIXME(-Znext-solver=coinductive): Are these even coinductive? AliasBoundConstCondition, - /// Instantiating a higher-ranked goal and re-proving it. - InstantiateHigherRanked, /// Predicate required for an alias projection to be well-formed. /// This is used in two places: projecting to an opaque whose hidden type /// is already registered in the opaque type storage, and for rigid projections. diff --git a/tests/ui/coherence/coherence-overlap-unnormalizable-projection-1.stderr b/tests/ui/coherence/coherence-overlap-unnormalizable-projection-1.stderr index 22673cef64079..c92854b92f9d3 100644 --- a/tests/ui/coherence/coherence-overlap-unnormalizable-projection-1.stderr +++ b/tests/ui/coherence/coherence-overlap-unnormalizable-projection-1.stderr @@ -12,7 +12,7 @@ LL | impl Trait for Box {} | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` | = note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>` - = note: downstream crates may implement trait `WhereBound` for type `std::boxed::Box<_>` + = note: downstream crates may implement trait `WhereBound` for type `std::boxed::Box< as WithAssoc<'a>>::Assoc>` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.next.stderr b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.next.stderr deleted file mode 100644 index 90391b7b86b5c..0000000000000 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.next.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: the trait bound `for<'a> &'a &T: Trait` is not satisfied - --> $DIR/candidate-from-env-universe-err-1.rs:27:16 - | -LL | hr_bound::<&T>(); - | ^^ the trait `for<'a> Trait` is not implemented for `&'a &T` - | -note: required by a bound in `hr_bound` - --> $DIR/candidate-from-env-universe-err-1.rs:14:20 - | -LL | fn hr_bound() - | -------- required by a bound in this function -LL | where -LL | for<'a> &'a T: Trait, - | ^^^^^ required by this bound in `hr_bound` -help: consider removing the leading `&`-reference - | -LL - hr_bound::<&T>(); -LL + hr_bound::(); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.rs b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.rs index bd251216162db..1fc08b2abcead 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.rs +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-1.rs @@ -1,6 +1,6 @@ //@ revisions: old next //@[next] compile-flags: -Znext-solver -//@[old] check-pass +//@ check-pass // cc #119820 @@ -25,7 +25,6 @@ where // the leak check both candidates may apply and we prefer the // `param_env` candidate in winnowing. hr_bound::<&T>(); - //[next]~^ ERROR the trait bound `for<'a> &'a &T: Trait` is not satisfied } fn main() {} diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.next.stderr b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.next.stderr deleted file mode 100644 index 0f5a9de7ab854..0000000000000 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.next.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `for<'a> T: Trait<'a, '_>` is not satisfied - --> $DIR/candidate-from-env-universe-err-2.rs:15:15 - | -LL | impl_hr::(); - | ^ the trait `for<'a> Trait<'a, '_>` is not implemented for `T` - | -note: required by a bound in `impl_hr` - --> $DIR/candidate-from-env-universe-err-2.rs:12:19 - | -LL | fn impl_hr<'b, T: for<'a> Trait<'a, 'b>>() {} - | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `impl_hr` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.rs b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.rs index 0132b7db60574..dcdff28ad15e9 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.rs +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-2.rs @@ -1,6 +1,6 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver -//@[current] check-pass +//@ check-pass // cc #119820 @@ -13,7 +13,6 @@ fn impl_hr<'b, T: for<'a> Trait<'a, 'b>>() {} fn not_hr<'a, T: for<'b> Trait<'a, 'b> + OtherTrait<'static>>() { impl_hr::(); - //[next]~^ ERROR the trait bound `for<'a> T: Trait<'a, '_>` is not satisfied } fn main() {} diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr index 7b9fd6bb4c571..324e1571a936a 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/candidate-from-env-universe-err-project.rs:38:5 + --> $DIR/candidate-from-env-universe-err-project.rs:37:5 | LL | projection_bound::(); | ^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -13,7 +13,7 @@ LL | fn projection_bound Trait<'a, Assoc = usize>>() {} | ^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/candidate-from-env-universe-err-project.rs:53:30 + --> $DIR/candidate-from-env-universe-err-project.rs:51:30 | LL | let _higher_ranked_norm: for<'a> fn(>::Assoc) = |_| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -22,7 +22,7 @@ LL | let _higher_ranked_norm: for<'a> fn(>::Assoc) = |_| (); found associated type `>::Assoc` error[E0308]: mismatched types - --> $DIR/candidate-from-env-universe-err-project.rs:53:30 + --> $DIR/candidate-from-env-universe-err-project.rs:51:30 | LL | let _higher_ranked_norm: for<'a> fn(>::Assoc) = |_| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.next.stderr b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.next.stderr index 6e0ec5620da0c..310d2b3d33501 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.next.stderr +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.next.stderr @@ -1,29 +1,5 @@ -error[E0277]: the trait bound `for<'a> T: Trait<'a>` is not satisfied - --> $DIR/candidate-from-env-universe-err-project.rs:28:19 - | -LL | trait_bound::(); - | ^ the trait `for<'a> Trait<'a>` is not implemented for `T` - | -note: required by a bound in `trait_bound` - --> $DIR/candidate-from-env-universe-err-project.rs:17:19 - | -LL | fn trait_bound Trait<'a>>() {} - | ^^^^^^^^^^^^^^^^^ required by this bound in `trait_bound` - -error[E0277]: the trait bound `for<'a> T: Trait<'a>` is not satisfied - --> $DIR/candidate-from-env-universe-err-project.rs:38:24 - | -LL | projection_bound::(); - | ^ the trait `for<'a> Trait<'a>` is not implemented for `T` - | -note: required by a bound in `projection_bound` - --> $DIR/candidate-from-env-universe-err-project.rs:18:24 - | -LL | fn projection_bound Trait<'a, Assoc = usize>>() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `projection_bound` - error[E0271]: type mismatch resolving `>::Assoc == usize` - --> $DIR/candidate-from-env-universe-err-project.rs:38:24 + --> $DIR/candidate-from-env-universe-err-project.rs:37:24 | LL | projection_bound::(); | ^ type mismatch resolving `>::Assoc == usize` @@ -40,20 +16,19 @@ LL | fn projection_bound Trait<'a, Assoc = usize>>() {} | ^^^^^^^^^^^^^ required by this bound in `projection_bound` error: higher-ranked subtype error - --> $DIR/candidate-from-env-universe-err-project.rs:53:30 + --> $DIR/candidate-from-env-universe-err-project.rs:51:30 | LL | let _higher_ranked_norm: for<'a> fn(>::Assoc) = |_| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: higher-ranked subtype error - --> $DIR/candidate-from-env-universe-err-project.rs:53:30 + --> $DIR/candidate-from-env-universe-err-project.rs:51:30 | LL | let _higher_ranked_norm: for<'a> fn(>::Assoc) = |_| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0271, E0277. -For more information about an error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.rs b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.rs index a77d87f6fa78e..1cf3052f3af8c 100644 --- a/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.rs +++ b/tests/ui/higher-ranked/leak-check/candidate-from-env-universe-err-project.rs @@ -20,13 +20,12 @@ fn projection_bound Trait<'a, Assoc = usize>>() {} // We use a function with a trivial where-bound which is more // restrictive than the impl. fn function1>() { - // err + // ok // // Proving `for<'a> T: Trait<'a>` using the where-bound does not // result in a leak check failure even though it does not apply. // We prefer env candidates over impl candidatescausing this to succeed. trait_bound::(); - //[next]~^ ERROR the trait bound `for<'a> T: Trait<'a>` is not satisfied } fn function2>() { @@ -37,8 +36,7 @@ fn function2>() { // to prefer it over the impl, resulting in a placeholder error. projection_bound::(); //[next]~^ ERROR type mismatch resolving `>::Assoc == usize` - //[next]~| ERROR the trait bound `for<'a> T: Trait<'a>` is not satisfied - //[current]~^^^ ERROR mismatched types + //[current]~^^ ERROR mismatched types } fn function3>() { diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.next.stderr b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.next.stderr deleted file mode 100644 index cb97bc4b8fc6e..0000000000000 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.next.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-2.rs:17:5 - | -LL | impls_trait::<(), _>(); - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `impls_trait` - | -note: multiple `impl`s satisfying `for<'a> (): Trait<&'a str, _>` found - --> $DIR/leak-check-in-selection-2.rs:10:1 - | -LL | impl<'a> Trait<&'a str, &'a str> for () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | impl<'a> Trait<&'a str, String> for () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `impls_trait` - --> $DIR/leak-check-in-selection-2.rs:14:19 - | -LL | fn impls_trait Trait<&'a str, U>, U>() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `impls_trait` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs index 24e38ec45a2c4..67188b17957ac 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs @@ -1,6 +1,6 @@ //@ revisions: old next //@[next] compile-flags: -Znext-solver -//@[old] check-pass +//@ check-pass // cc #119820 @@ -15,5 +15,4 @@ fn impls_trait Trait<&'a str, U>, U>() {} fn main() { impls_trait::<(), _>(); - //[next]~^ ERROR type annotations needed } diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.next.stderr b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.next.stderr index 5be683cd3191b..990586601748a 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.next.stderr +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.next.stderr @@ -1,24 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-3.rs:18:5 - | -LL | impls_leak::>(); - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls_leak` - | -note: multiple `impl`s satisfying `for<'a> Box<_>: Leak<'a>` found - --> $DIR/leak-check-in-selection-3.rs:9:1 - | -LL | impl Leak<'_> for Box {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | impl Leak<'static> for Box {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `impls_leak` - --> $DIR/leak-check-in-selection-3.rs:12:18 - | -LL | fn impls_leak Leak<'a>>() {} - | ^^^^^^^^^^^^^^^^ required by this bound in `impls_leak` - -error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-3.rs:35:5 + --> $DIR/leak-check-in-selection-3.rs:34:5 | LL | impls_indirect_leak::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls_indirect_leak` @@ -31,18 +12,18 @@ LL | impl Leak<'_> for Box {} LL | impl Leak<'static> for Box {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required for `Box<_>` to implement `for<'a> IndirectLeak<'a>` - --> $DIR/leak-check-in-selection-3.rs:23:23 + --> $DIR/leak-check-in-selection-3.rs:22:23 | LL | impl<'a, T: Leak<'a>> IndirectLeak<'a> for T {} | -------- ^^^^^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here note: required by a bound in `impls_indirect_leak` - --> $DIR/leak-check-in-selection-3.rs:25:27 + --> $DIR/leak-check-in-selection-3.rs:24:27 | LL | fn impls_indirect_leak IndirectLeak<'a>>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `impls_indirect_leak` -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.old.stderr b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.old.stderr index 194571dd4a85b..d78a90209f33a 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.old.stderr +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.old.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-3.rs:35:5 + --> $DIR/leak-check-in-selection-3.rs:34:5 | LL | impls_indirect_leak::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls_indirect_leak` @@ -12,14 +12,14 @@ LL | impl Leak<'_> for Box {} LL | impl Leak<'static> for Box {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required for `Box<_>` to implement `for<'a> IndirectLeak<'a>` - --> $DIR/leak-check-in-selection-3.rs:23:23 + --> $DIR/leak-check-in-selection-3.rs:22:23 | LL | impl<'a, T: Leak<'a>> IndirectLeak<'a> for T {} | -------- ^^^^^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here note: required by a bound in `impls_indirect_leak` - --> $DIR/leak-check-in-selection-3.rs:25:27 + --> $DIR/leak-check-in-selection-3.rs:24:27 | LL | fn impls_indirect_leak IndirectLeak<'a>>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `impls_indirect_leak` diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.rs b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.rs index 9aa1be57a4fb2..c51dd797e24f9 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.rs +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-3.rs @@ -16,7 +16,6 @@ fn direct() { // The `Box` impls fails the leak check, // meaning that we apply the `Box` impl. impls_leak::>(); - //[next]~^ ERROR type annotations needed } trait IndirectLeak<'a> {} diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.next.stderr b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.next.stderr deleted file mode 100644 index a12e3312230af..0000000000000 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.next.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:30:5 - | -LL | impls_trait::<(), _, _>() - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `impls_trait` - | -note: multiple `impl`s satisfying `(): Trait<_, _>` found - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:26:1 - | -LL | impl Trait for () where for<'b> (): LeakCheckFailure<'static, 'b, V> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | impl Trait for () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `impls_trait` - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:28:19 - | -LL | fn impls_trait, U: Id, V>() {} - | ^^^^^^^^^^^ required by this bound in `impls_trait` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.old.stderr b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.old.stderr index a12e3312230af..8a69add08afcf 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.old.stderr +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.old.stderr @@ -1,18 +1,18 @@ error[E0283]: type annotations needed - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:30:5 + --> $DIR/leak-check-in-selection-6-ambig-unify.rs:31:5 | LL | impls_trait::<(), _, _>() | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `impls_trait` | note: multiple `impl`s satisfying `(): Trait<_, _>` found - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:26:1 + --> $DIR/leak-check-in-selection-6-ambig-unify.rs:27:1 | LL | impl Trait for () where for<'b> (): LeakCheckFailure<'static, 'b, V> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | impl Trait for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `impls_trait` - --> $DIR/leak-check-in-selection-6-ambig-unify.rs:28:19 + --> $DIR/leak-check-in-selection-6-ambig-unify.rs:29:19 | LL | fn impls_trait, U: Id, V>() {} | ^^^^^^^^^^^ required by this bound in `impls_trait` diff --git a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs index 592d581695e52..47063b118b82d 100644 --- a/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs +++ b/tests/ui/higher-ranked/leak-check/leak-check-in-selection-6-ambig-unify.rs @@ -1,5 +1,6 @@ //@ revisions: old next //@[next] compile-flags: -Znext-solver +//@[next] check-pass // The new trait solver does not return region constraints if the goal // is still ambiguous. This should cause the following test to fail with @@ -28,5 +29,5 @@ impl Trait for () {} fn impls_trait, U: Id, V>() {} fn main() { impls_trait::<(), _, _>() - //~^ ERROR type annotations needed + //[old]~^ ERROR type annotations needed } diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed index ba46a447802c8..74a0c695a780b 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed @@ -9,5 +9,6 @@ fn main() { let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` + //[next]~| ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` //[next]~| ERROR expected a `FnMut(& as Iterator>::Item)` closure, found } diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr index b716131061993..6d27c08f5e90a 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr @@ -32,7 +32,18 @@ LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 3 previous errors +error[E0271]: expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` + --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:29 + | +LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&&i32`, found integer + | | + | required by a bound introduced by this call + | +note: required by a bound in `find` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0271, E0277. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs index 0fd56707763e9..c99fb2bc1b17b 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs @@ -9,5 +9,6 @@ fn main() { let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` + //[next]~| ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` //[next]~| ERROR expected a `FnMut(& as Iterator>::Item)` closure, found }