From e82c3c80ef3ad1389d6d8b12f8ac9128e53c4cc5 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 11:57:45 +0800 Subject: [PATCH 1/6] add a new normalization routine that can handle ambiguity --- compiler/rustc_next_trait_solver/src/lib.rs | 1 + .../rustc_next_trait_solver/src/normalize.rs | 242 +++++++++++++ .../src/placeholder.rs | 153 ++++++++ compiler/rustc_trait_selection/src/solve.rs | 2 +- .../src/solve/normalize.rs | 336 +++++++++--------- .../src/traits/normalize.rs | 3 +- .../rustc_trait_selection/src/traits/util.rs | 155 +------- 7 files changed, 565 insertions(+), 327 deletions(-) create mode 100644 compiler/rustc_next_trait_solver/src/normalize.rs diff --git a/compiler/rustc_next_trait_solver/src/lib.rs b/compiler/rustc_next_trait_solver/src/lib.rs index 5fa29b7d9f813..57bbf8772d322 100644 --- a/compiler/rustc_next_trait_solver/src/lib.rs +++ b/compiler/rustc_next_trait_solver/src/lib.rs @@ -13,6 +13,7 @@ pub mod canonical; pub mod coherence; pub mod delegate; +pub mod normalize; pub mod placeholder; pub mod resolve; pub mod solve; diff --git a/compiler/rustc_next_trait_solver/src/normalize.rs b/compiler/rustc_next_trait_solver/src/normalize.rs new file mode 100644 index 0000000000000..7506591d6fb5d --- /dev/null +++ b/compiler/rustc_next_trait_solver/src/normalize.rs @@ -0,0 +1,242 @@ +use rustc_type_ir::data_structures::ensure_sufficient_stack; +use rustc_type_ir::inherent::*; +use rustc_type_ir::solve::{Goal, NoSolution}; +use rustc_type_ir::{ + self as ty, Binder, FallibleTypeFolder, InferConst, InferCtxtLike, InferTy, Interner, + TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, + TypeVisitor, UniverseIndex, +}; +use tracing::instrument; + +use crate::placeholder::{BoundVarReplacer, PlaceholderReplacer}; + +/// This folder normalizes value and collects ambiguous goals. +/// +/// Note that for ambiguous alias which contains escaping bound vars, +/// we just return the original alias and don't collect the ambiguous goal. +pub struct NormalizationFolder<'a, Infcx, I, F> +where + Infcx: InferCtxtLike, + I: Interner, +{ + infcx: &'a Infcx, + universes: Vec>, + stalled_goals: Vec>, + normalize: F, +} + +#[derive(PartialEq, Eq)] +enum HasEscapingBoundVars { + Yes, + No, +} + +/// Finds the max universe present in infer vars. +struct MaxUniverse<'a, Infcx, I> +where + Infcx: InferCtxtLike, + I: Interner, +{ + infcx: &'a Infcx, + max_universe: ty::UniverseIndex, +} + +impl<'a, Infcx, I> MaxUniverse<'a, Infcx, I> +where + Infcx: InferCtxtLike, + I: Interner, +{ + fn new(infcx: &'a Infcx) -> Self { + MaxUniverse { infcx, max_universe: ty::UniverseIndex::ROOT } + } + + fn max_universe(self) -> ty::UniverseIndex { + self.max_universe + } +} + +impl<'a, Infcx, I> TypeVisitor for MaxUniverse<'a, Infcx, I> +where + Infcx: InferCtxtLike, + I: Interner, +{ + type Result = (); + + fn visit_ty(&mut self, t: I::Ty) { + if !t.has_infer() { + return; + } + + if let ty::Infer(InferTy::TyVar(vid)) = t.kind() { + // We shallow resolved the infer var before. + // So it should be a unresolved infer var with an universe. + self.max_universe = self.max_universe.max(self.infcx.universe_of_ty(vid).unwrap()); + } + + t.super_visit_with(self) + } + + fn visit_const(&mut self, c: I::Const) { + if !c.has_infer() { + return; + } + + if let ty::ConstKind::Infer(InferConst::Var(vid)) = c.kind() { + // We shallow resolved the infer var before. + // So it should be a unresolved infer var with an universe. + self.max_universe = self.max_universe.max(self.infcx.universe_of_ct(vid).unwrap()); + } + + c.super_visit_with(self) + } + + fn visit_region(&mut self, r: I::Region) { + if let ty::ReVar(vid) = r.kind() { + self.max_universe = self.max_universe.max(self.infcx.universe_of_lt(vid).unwrap()); + } + } +} + +impl<'a, Infcx, I, F> NormalizationFolder<'a, Infcx, I, F> +where + Infcx: InferCtxtLike, + I: Interner, + F: FnMut(I::Term) -> Result<(I::Term, Option>), NoSolution>, +{ + pub fn new( + infcx: &'a Infcx, + universes: Vec>, + stalled_goals: Vec>, + normalize: F, + ) -> Self { + Self { infcx, universes, stalled_goals, normalize } + } + + pub fn stalled_goals(self) -> Vec> { + self.stalled_goals + } + + fn normalize_alias_term( + &mut self, + alias_term: I::Term, + has_escaping: HasEscapingBoundVars, + ) -> Result { + let current_universe = self.infcx.universe(); + self.infcx.create_next_universe(); + + let (normalized, ambig_goal) = (self.normalize)(alias_term)?; + + // Return ambiguous higher ranked alias as is, if + // - it contains escaping vars, and + // - the normalized term contains infer vars newly created + // in the normalization above. + // The problem is that they may be resolved to types + // referencing the temporary placeholders. + // + // We can normalize the ambiguous alias again after the binder is instantiated. + if ambig_goal.is_some() && has_escaping == HasEscapingBoundVars::Yes { + let mut visitor = MaxUniverse::new(self.infcx); + normalized.visit_with(&mut visitor); + let max_universe = visitor.max_universe(); + if current_universe.cannot_name(max_universe) { + return Ok(alias_term); + } + } + + self.stalled_goals.extend(ambig_goal); + Ok(normalized) + } +} + +impl<'a, Infcx, I, F> FallibleTypeFolder for NormalizationFolder<'a, Infcx, I, F> +where + Infcx: InferCtxtLike, + I: Interner, + F: FnMut(I::Term) -> Result<(I::Term, Option>), NoSolution>, +{ + type Error = NoSolution; + + fn cx(&self) -> I { + self.infcx.cx() + } + + fn try_fold_binder>( + &mut self, + t: Binder, + ) -> Result, Self::Error> { + self.universes.push(None); + let t = t.try_super_fold_with(self)?; + self.universes.pop(); + Ok(t) + } + + #[instrument(level = "trace", skip(self), ret)] + fn try_fold_ty(&mut self, ty: I::Ty) -> Result { + let infcx = self.infcx; + if !ty.has_aliases() { + return Ok(ty); + } + + // With eager normalization, we should normalize the args of alias before + // normalizing the alias itself. + let ty = ty.try_super_fold_with(self)?; + let ty::Alias(..) = ty.kind() else { return Ok(ty) }; + + if ty.has_escaping_bound_vars() { + let (ty, mapped_regions, mapped_types, mapped_consts) = + BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, ty); + let result = ensure_sufficient_stack(|| { + self.normalize_alias_term(ty.into(), HasEscapingBoundVars::Yes) + })? + .expect_ty(); + Ok(PlaceholderReplacer::replace_placeholders( + infcx, + mapped_regions, + mapped_types, + mapped_consts, + &self.universes, + result, + )) + } else { + Ok(ensure_sufficient_stack(|| { + self.normalize_alias_term(ty.into(), HasEscapingBoundVars::No) + })? + .expect_ty()) + } + } + + #[instrument(level = "trace", skip(self), ret)] + fn try_fold_const(&mut self, ct: I::Const) -> Result { + let infcx = self.infcx; + if !ct.has_aliases() { + return Ok(ct); + } + + // With eager normalization, we should normalize the args of alias before + // normalizing the alias itself. + let ct = ct.try_super_fold_with(self)?; + let ty::ConstKind::Unevaluated(..) = ct.kind() else { return Ok(ct) }; + + if ct.has_escaping_bound_vars() { + let (ct, mapped_regions, mapped_types, mapped_consts) = + BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, ct); + let result = ensure_sufficient_stack(|| { + self.normalize_alias_term(ct.into(), HasEscapingBoundVars::Yes) + })? + .expect_const(); + Ok(PlaceholderReplacer::replace_placeholders( + infcx, + mapped_regions, + mapped_types, + mapped_consts, + &self.universes, + result, + )) + } else { + Ok(ensure_sufficient_stack(|| { + self.normalize_alias_term(ct.into(), HasEscapingBoundVars::No) + })? + .expect_const()) + } + } +} diff --git a/compiler/rustc_next_trait_solver/src/placeholder.rs b/compiler/rustc_next_trait_solver/src/placeholder.rs index 83f3bdf01dc83..b5bb488c43b89 100644 --- a/compiler/rustc_next_trait_solver/src/placeholder.rs +++ b/compiler/rustc_next_trait_solver/src/placeholder.rs @@ -6,6 +6,7 @@ use rustc_type_ir::{ self as ty, InferCtxtLike, Interner, PlaceholderConst, PlaceholderRegion, PlaceholderType, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; +use tracing::debug; pub struct BoundVarReplacer<'a, Infcx, I = ::Interner> where @@ -164,3 +165,155 @@ where if p.has_vars_bound_at_or_above(self.current_index) { p.super_fold_with(self) } else { p } } } + +/// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came. +pub struct PlaceholderReplacer<'a, Infcx, I = ::Interner> +where + Infcx: InferCtxtLike, + I: Interner, +{ + infcx: &'a Infcx, + mapped_regions: IndexMap, ty::BoundRegion>, + mapped_types: IndexMap, ty::BoundTy>, + mapped_consts: IndexMap, ty::BoundConst>, + universe_indices: &'a [Option], + current_index: ty::DebruijnIndex, +} + +impl<'a, Infcx, I> PlaceholderReplacer<'a, Infcx, I> +where + Infcx: InferCtxtLike, + I: Interner, +{ + pub fn replace_placeholders>( + infcx: &'a Infcx, + mapped_regions: IndexMap, ty::BoundRegion>, + mapped_types: IndexMap, ty::BoundTy>, + mapped_consts: IndexMap, ty::BoundConst>, + universe_indices: &'a [Option], + value: T, + ) -> T { + let mut replacer = PlaceholderReplacer { + infcx, + mapped_regions, + mapped_types, + mapped_consts, + universe_indices, + current_index: ty::INNERMOST, + }; + value.fold_with(&mut replacer) + } +} + +impl<'a, Infcx, I> TypeFolder for PlaceholderReplacer<'a, Infcx, I> +where + Infcx: InferCtxtLike, + I: Interner, +{ + fn cx(&self) -> I { + self.infcx.cx() + } + + fn fold_binder>(&mut self, t: ty::Binder) -> ty::Binder { + if !t.has_placeholders() && !t.has_infer() { + return t; + } + self.current_index.shift_in(1); + let t = t.super_fold_with(self); + self.current_index.shift_out(1); + t + } + + fn fold_region(&mut self, r0: I::Region) -> I::Region { + let r1 = match r0.kind() { + ty::ReVar(vid) => self.infcx.opportunistic_resolve_lt_var(vid), + _ => r0, + }; + + let r2 = match r1.kind() { + ty::RePlaceholder(p) => { + let replace_var = self.mapped_regions.get(&p); + match replace_var { + Some(replace_var) => { + let index = self + .universe_indices + .iter() + .position(|u| matches!(u, Some(pu) if *pu == p.universe)) + .unwrap_or_else(|| panic!("Unexpected placeholder universe.")); + let db = ty::DebruijnIndex::from_usize( + self.universe_indices.len() - index + self.current_index.as_usize() - 1, + ); + Region::new_bound(self.cx(), db, *replace_var) + } + None => r1, + } + } + _ => r1, + }; + + debug!(?r0, ?r1, ?r2, "fold_region"); + + r2 + } + + fn fold_ty(&mut self, ty: I::Ty) -> I::Ty { + let ty = self.infcx.shallow_resolve(ty); + match ty.kind() { + ty::Placeholder(p) => { + let replace_var = self.mapped_types.get(&p); + match replace_var { + Some(replace_var) => { + let index = self + .universe_indices + .iter() + .position(|u| matches!(u, Some(pu) if *pu == p.universe)) + .unwrap_or_else(|| panic!("Unexpected placeholder universe.")); + let db = ty::DebruijnIndex::from_usize( + self.universe_indices.len() - index + self.current_index.as_usize() - 1, + ); + Ty::new_bound(self.infcx.cx(), db, *replace_var) + } + None => { + if ty.has_infer() { + ty.super_fold_with(self) + } else { + ty + } + } + } + } + + _ if ty.has_placeholders() || ty.has_infer() => ty.super_fold_with(self), + _ => ty, + } + } + + fn fold_const(&mut self, ct: I::Const) -> I::Const { + let ct = self.infcx.shallow_resolve_const(ct); + if let ty::ConstKind::Placeholder(p) = ct.kind() { + let replace_var = self.mapped_consts.get(&p); + match replace_var { + Some(replace_var) => { + let index = self + .universe_indices + .iter() + .position(|u| matches!(u, Some(pu) if *pu == p.universe)) + .unwrap_or_else(|| panic!("Unexpected placeholder universe.")); + let db = ty::DebruijnIndex::from_usize( + self.universe_indices.len() - index + self.current_index.as_usize() - 1, + ); + Const::new_bound(self.infcx.cx(), db, *replace_var) + } + None => { + if ct.has_infer() { + ct.super_fold_with(self) + } else { + ct + } + } + } + } else { + ct.super_fold_with(self) + } + } +} diff --git a/compiler/rustc_trait_selection/src/solve.rs b/compiler/rustc_trait_selection/src/solve.rs index 518861fbd031d..3361780196e26 100644 --- a/compiler/rustc_trait_selection/src/solve.rs +++ b/compiler/rustc_trait_selection/src/solve.rs @@ -11,7 +11,7 @@ pub use fulfill::{FulfillmentCtxt, NextSolverError}; pub(crate) use normalize::deeply_normalize_for_diagnostics; pub use normalize::{ deeply_normalize, deeply_normalize_with_skipped_universes, - deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals, + deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals, normalize, }; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs index 0d5a8ab98f262..7c21dc161a1ec 100644 --- a/compiler/rustc_trait_selection/src/solve/normalize.rs +++ b/compiler/rustc_trait_selection/src/solve/normalize.rs @@ -1,21 +1,158 @@ -use std::fmt::Debug; - -use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_infer::infer::InferCtxt; use rustc_infer::infer::at::At; use rustc_infer::traits::solve::Goal; -use rustc_infer::traits::{FromSolverError, Obligation, TraitEngine}; +use rustc_infer::traits::{ + FromSolverError, Normalized, Obligation, PredicateObligations, TraitEngine, +}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::{ - self, FallibleTypeFolder, Flags, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, - TypeVisitableExt, UniverseIndex, Unnormalized, + self, Binder, Flags, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, + UniverseIndex, Unnormalized, }; -use tracing::instrument; +use rustc_next_trait_solver::normalize::NormalizationFolder; +use rustc_next_trait_solver::solve::SolverDelegateEvalExt; use super::{FulfillmentCtxt, NextSolverError}; -use crate::error_reporting::InferCtxtErrorExt; -use crate::error_reporting::traits::OverflowCause; -use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError}; +use crate::solve::{Certainty, SolverDelegate}; +use crate::traits::{BoundVarReplacer, ScrubbedTraitError}; + +/// see `normalize_with_universes`. +pub fn normalize<'tcx, T>(at: At<'_, 'tcx>, value: Unnormalized<'tcx, T>) -> Normalized<'tcx, T> +where + T: TypeFoldable>, +{ + normalize_with_universes(at, value, vec![]) +} + +/// Like `deeply_normalize`, but we handle ambiguity and inference variables in this routine. +/// The behavior should be same as the old solver. +/// For error, we return an infer var plus the failed obligation. +/// For ambiguity, we have two cases: +/// - has_escaping_bound_vars: return the original alias. +/// - otherwise: return the normalized result. It can be (partially) inferred +/// even if the evaluation result is ambiguous. +fn normalize_with_universes<'tcx, T>( + at: At<'_, 'tcx>, + value: Unnormalized<'tcx, T>, + universes: Vec>, +) -> Normalized<'tcx, T> +where + T: TypeFoldable>, +{ + let infcx = at.infcx; + let value = value.skip_normalization(); + let value = infcx.resolve_vars_if_possible(value); + let original_value = value.clone(); + let mut folder = + NormalizationFolder::new(infcx, universes.clone(), Default::default(), |alias_term| { + let delegate = <&SolverDelegate<'tcx>>::from(infcx); + let infer_term = delegate.next_term_var_of_kind(alias_term, at.cause.span); + let predicate = ty::PredicateKind::AliasRelate( + alias_term.into(), + infer_term.into(), + ty::AliasRelationDirection::Equate, + ); + let goal = Goal::new(infcx.tcx, at.param_env, predicate); + let result = delegate.evaluate_root_goal(goal, at.cause.span, None)?; + let normalized = infcx.resolve_vars_if_possible(infer_term); + let stalled_goal = match result.certainty { + Certainty::Yes => None, + Certainty::Maybe { .. } => Some(infcx.resolve_vars_if_possible(result.goal)), + }; + Ok((normalized, stalled_goal)) + }); + if let Ok(value) = value.try_fold_with(&mut folder) { + let obligations = folder + .stalled_goals() + .into_iter() + .map(|goal| { + Obligation::new(infcx.tcx, at.cause.clone(), goal.param_env, goal.predicate) + }) + .collect(); + Normalized { value, obligations } + } else { + let mut replacer = ReplaceAliasWithInfer { at, obligations: Default::default(), universes }; + let value = original_value.fold_with(&mut replacer); + Normalized { value, obligations: replacer.obligations } + } +} + +struct ReplaceAliasWithInfer<'me, 'tcx> { + at: At<'me, 'tcx>, + obligations: PredicateObligations<'tcx>, + universes: Vec>, +} + +impl<'me, 'tcx> ReplaceAliasWithInfer<'me, 'tcx> { + fn term_to_infer(&mut self, alias_term: ty::Term<'tcx>) -> ty::Term<'tcx> { + let infcx = self.at.infcx; + let infer_term = infcx.next_term_var_of_kind(alias_term, self.at.cause.span); + let obligation = Obligation::new( + infcx.tcx, + self.at.cause.clone(), + self.at.param_env, + ty::PredicateKind::AliasRelate( + alias_term.into(), + infer_term.into(), + ty::AliasRelationDirection::Equate, + ), + ); + self.obligations.push(obligation); + infer_term + } +} + +impl<'me, 'tcx> TypeFolder> for ReplaceAliasWithInfer<'me, 'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { + self.at.infcx.tcx + } + + fn fold_binder>>( + &mut self, + t: Binder<'tcx, T>, + ) -> Binder<'tcx, T> { + self.universes.push(None); + let t = t.super_fold_with(self); + self.universes.pop(); + t + } + + fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { + if !ty.has_aliases() { + return ty; + } + + let ty = ty.super_fold_with(self); + let ty::Alias(..) = *ty.kind() else { return ty }; + + if ty.has_escaping_bound_vars() { + let (replaced, ..) = + BoundVarReplacer::replace_bound_vars(self.at.infcx, &mut self.universes, ty); + let _ = self.term_to_infer(replaced.into()); + ty + } else { + self.term_to_infer(ty.into()).expect_type() + } + } + + fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { + if !ct.has_aliases() { + return ct; + } + + let ct = ct.super_fold_with(self); + let ty::ConstKind::Unevaluated(..) = ct.kind() else { return ct }; + + if ct.has_escaping_bound_vars() { + let (replaced, ..) = + BoundVarReplacer::replace_bound_vars(self.at.infcx, &mut self.universes, ct); + let _ = self.term_to_infer(replaced.into()); + ct + } else { + self.term_to_infer(ct.into()).expect_const() + } + } +} /// Deeply normalize all aliases in `value`. This does not handle inference and expects /// its input to be already fully resolved. @@ -73,177 +210,30 @@ where T: TypeFoldable>, E: FromSolverError<'tcx, NextSolverError<'tcx>>, { - let value = value.skip_normalization(); - let fulfill_cx = FulfillmentCtxt::new(at.infcx); - let mut folder = NormalizationFolder { - at, - fulfill_cx, - depth: 0, - universes, - stalled_coroutine_goals: vec![], - }; - let value = value.try_fold_with(&mut folder)?; - let errors = folder.fulfill_cx.evaluate_obligations_error_on_ambiguity(at.infcx); - if errors.is_empty() { Ok((value, folder.stalled_coroutine_goals)) } else { Err(errors) } -} - -struct NormalizationFolder<'me, 'tcx, E> { - at: At<'me, 'tcx>, - fulfill_cx: FulfillmentCtxt<'tcx, E>, - depth: usize, - universes: Vec>, - stalled_coroutine_goals: Vec>>, -} - -impl<'tcx, E> NormalizationFolder<'_, 'tcx, E> -where - E: FromSolverError<'tcx, NextSolverError<'tcx>>, -{ - fn normalize_alias_term( - &mut self, - alias_term: ty::Term<'tcx>, - ) -> Result, Vec> { - let infcx = self.at.infcx; - let tcx = infcx.tcx; - let recursion_limit = tcx.recursion_limit(); - if !recursion_limit.value_within_limit(self.depth) { - let term = alias_term.to_alias_term(tcx).unwrap(); - - self.at.infcx.err_ctxt().report_overflow_error( - OverflowCause::DeeplyNormalize(term), - self.at.cause.span, - true, - |_| {}, - ); - } - - self.depth += 1; - - let infer_term = infcx.next_term_var_of_kind(alias_term, self.at.cause.span); - let obligation = Obligation::new( - tcx, - self.at.cause.clone(), - self.at.param_env, - ty::PredicateKind::AliasRelate( - alias_term.into(), - infer_term.into(), - ty::AliasRelationDirection::Equate, - ), - ); - - self.fulfill_cx.register_predicate_obligation(infcx, obligation); - self.evaluate_all_error_on_ambiguity_stall_coroutine_predicates()?; - - // Alias is guaranteed to be fully structurally resolved, - // so we can super fold here. - let term = infcx.resolve_vars_if_possible(infer_term); - // super-folding the `term` will directly fold the `Ty` or `Const` so - // we have to match on the term and super-fold them manually. - let result = match term.kind() { - ty::TermKind::Ty(ty) => ty.try_super_fold_with(self)?.into(), - ty::TermKind::Const(ct) => ct.try_super_fold_with(self)?.into(), - }; - self.depth -= 1; - Ok(result) - } - - fn evaluate_all_error_on_ambiguity_stall_coroutine_predicates(&mut self) -> Result<(), Vec> { - let errors = self.fulfill_cx.try_evaluate_obligations(self.at.infcx); - if !errors.is_empty() { - return Err(errors); - } - - self.stalled_coroutine_goals.extend( - self.fulfill_cx - .drain_stalled_obligations_for_coroutines(self.at.infcx) - .into_iter() - .map(|obl| obl.as_goal()), - ); - - let errors = self.fulfill_cx.collect_remaining_errors(self.at.infcx); - if !errors.is_empty() { - return Err(errors); - } - - Ok(()) - } -} - -impl<'tcx, E> FallibleTypeFolder> for NormalizationFolder<'_, 'tcx, E> -where - E: FromSolverError<'tcx, NextSolverError<'tcx>> + Debug, -{ - type Error = Vec; + let Normalized { value, obligations } = normalize_with_universes(at, value, universes); - fn cx(&self) -> TyCtxt<'tcx> { - self.at.infcx.tcx + let mut fulfill_cx = FulfillmentCtxt::new(at.infcx); + for pred in obligations { + fulfill_cx.register_predicate_obligation(at.infcx, pred); } - fn try_fold_binder>>( - &mut self, - t: ty::Binder<'tcx, T>, - ) -> Result, Self::Error> { - self.universes.push(None); - let t = t.try_super_fold_with(self)?; - self.universes.pop(); - Ok(t) + let errors = fulfill_cx.try_evaluate_obligations(at.infcx); + if !errors.is_empty() { + return Err(errors); } - #[instrument(level = "trace", skip(self), ret)] - fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result, Self::Error> { - let infcx = self.at.infcx; - debug_assert_eq!(ty, infcx.shallow_resolve(ty)); - if !ty.has_aliases() { - return Ok(ty); - } - - let ty::Alias(..) = *ty.kind() else { return ty.try_super_fold_with(self) }; + let stalled_coroutine_goals = fulfill_cx + .drain_stalled_obligations_for_coroutines(at.infcx) + .into_iter() + .map(|obl| obl.as_goal()) + .collect(); - if ty.has_escaping_bound_vars() { - let (ty, mapped_regions, mapped_types, mapped_consts) = - BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, ty); - let result = - ensure_sufficient_stack(|| self.normalize_alias_term(ty.into()))?.expect_type(); - Ok(PlaceholderReplacer::replace_placeholders( - infcx, - mapped_regions, - mapped_types, - mapped_consts, - &self.universes, - result, - )) - } else { - Ok(ensure_sufficient_stack(|| self.normalize_alias_term(ty.into()))?.expect_type()) - } + let errors = fulfill_cx.collect_remaining_errors(at.infcx); + if !errors.is_empty() { + return Err(errors); } - #[instrument(level = "trace", skip(self), ret)] - fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result, Self::Error> { - let infcx = self.at.infcx; - debug_assert_eq!(ct, infcx.shallow_resolve_const(ct)); - if !ct.has_aliases() { - return Ok(ct); - } - - let ty::ConstKind::Unevaluated(..) = ct.kind() else { return ct.try_super_fold_with(self) }; - - if ct.has_escaping_bound_vars() { - let (ct, mapped_regions, mapped_types, mapped_consts) = - BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, ct); - let result = - ensure_sufficient_stack(|| self.normalize_alias_term(ct.into()))?.expect_const(); - Ok(PlaceholderReplacer::replace_placeholders( - infcx, - mapped_regions, - mapped_types, - mapped_consts, - &self.universes, - result, - )) - } else { - Ok(ensure_sufficient_stack(|| self.normalize_alias_term(ct.into()))?.expect_const()) - } - } + Ok((value, stalled_coroutine_goals)) } // Deeply normalize a value and return it diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index 55f1f861921ea..26360c3972e37 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -34,7 +34,8 @@ impl<'tcx> At<'_, 'tcx> { ) -> InferOk<'tcx, T> { let value = value.skip_normalization(); if self.infcx.next_trait_solver() { - InferOk { value, obligations: PredicateObligations::new() } + let Normalized { value, obligations } = crate::solve::normalize(*self, value); + InferOk { value, obligations } } else { let mut selcx = SelectionContext::new(self.infcx); let Normalized { value, obligations } = diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 13209a204d862..e4da1fd1598f7 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -1,18 +1,17 @@ use std::collections::VecDeque; -use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; +use rustc_data_structures::fx::FxHashSet; use rustc_hir::LangItem; use rustc_hir::def_id::DefId; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::PolyTraitObligation; pub use rustc_infer::traits::util::*; -use rustc_middle::bug; use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::{ self, PolyTraitPredicate, PredicatePolarity, SizedTraitKind, TraitPredicate, TraitRef, Ty, - TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, Unnormalized, + TyCtxt, TypeFoldable, TypeVisitableExt, Unnormalized, }; -pub use rustc_next_trait_solver::placeholder::BoundVarReplacer; +pub use rustc_next_trait_solver::placeholder::{BoundVarReplacer, PlaceholderReplacer}; use rustc_span::Span; use smallvec::{SmallVec, smallvec}; use tracing::debug; @@ -218,154 +217,6 @@ pub fn with_replaced_escaping_bound_vars< } } -/// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came. -pub struct PlaceholderReplacer<'a, 'tcx> { - infcx: &'a InferCtxt<'tcx>, - mapped_regions: FxIndexMap, ty::BoundRegion<'tcx>>, - mapped_types: FxIndexMap, ty::BoundTy<'tcx>>, - mapped_consts: FxIndexMap, ty::BoundConst<'tcx>>, - universe_indices: &'a [Option], - current_index: ty::DebruijnIndex, -} - -impl<'a, 'tcx> PlaceholderReplacer<'a, 'tcx> { - pub fn replace_placeholders>>( - infcx: &'a InferCtxt<'tcx>, - mapped_regions: FxIndexMap, ty::BoundRegion<'tcx>>, - mapped_types: FxIndexMap, ty::BoundTy<'tcx>>, - mapped_consts: FxIndexMap, ty::BoundConst<'tcx>>, - universe_indices: &'a [Option], - value: T, - ) -> T { - let mut replacer = PlaceholderReplacer { - infcx, - mapped_regions, - mapped_types, - mapped_consts, - universe_indices, - current_index: ty::INNERMOST, - }; - value.fold_with(&mut replacer) - } -} - -impl<'tcx> TypeFolder> for PlaceholderReplacer<'_, 'tcx> { - fn cx(&self) -> TyCtxt<'tcx> { - self.infcx.tcx - } - - fn fold_binder>>( - &mut self, - t: ty::Binder<'tcx, T>, - ) -> ty::Binder<'tcx, T> { - if !t.has_placeholders() && !t.has_infer() { - return t; - } - self.current_index.shift_in(1); - let t = t.super_fold_with(self); - self.current_index.shift_out(1); - t - } - - fn fold_region(&mut self, r0: ty::Region<'tcx>) -> ty::Region<'tcx> { - let r1 = match r0.kind() { - ty::ReVar(vid) => self - .infcx - .inner - .borrow_mut() - .unwrap_region_constraints() - .opportunistic_resolve_var(self.infcx.tcx, vid), - _ => r0, - }; - - let r2 = match r1.kind() { - ty::RePlaceholder(p) => { - let replace_var = self.mapped_regions.get(&p); - match replace_var { - Some(replace_var) => { - let index = self - .universe_indices - .iter() - .position(|u| matches!(u, Some(pu) if *pu == p.universe)) - .unwrap_or_else(|| bug!("Unexpected placeholder universe.")); - let db = ty::DebruijnIndex::from_usize( - self.universe_indices.len() - index + self.current_index.as_usize() - 1, - ); - ty::Region::new_bound(self.cx(), db, *replace_var) - } - None => r1, - } - } - _ => r1, - }; - - debug!(?r0, ?r1, ?r2, "fold_region"); - - r2 - } - - fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - let ty = self.infcx.shallow_resolve(ty); - match *ty.kind() { - ty::Placeholder(p) => { - let replace_var = self.mapped_types.get(&p); - match replace_var { - Some(replace_var) => { - let index = self - .universe_indices - .iter() - .position(|u| matches!(u, Some(pu) if *pu == p.universe)) - .unwrap_or_else(|| bug!("Unexpected placeholder universe.")); - let db = ty::DebruijnIndex::from_usize( - self.universe_indices.len() - index + self.current_index.as_usize() - 1, - ); - Ty::new_bound(self.infcx.tcx, db, *replace_var) - } - None => { - if ty.has_infer() { - ty.super_fold_with(self) - } else { - ty - } - } - } - } - - _ if ty.has_placeholders() || ty.has_infer() => ty.super_fold_with(self), - _ => ty, - } - } - - fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { - let ct = self.infcx.shallow_resolve_const(ct); - if let ty::ConstKind::Placeholder(p) = ct.kind() { - let replace_var = self.mapped_consts.get(&p); - match replace_var { - Some(replace_var) => { - let index = self - .universe_indices - .iter() - .position(|u| matches!(u, Some(pu) if *pu == p.universe)) - .unwrap_or_else(|| bug!("Unexpected placeholder universe.")); - let db = ty::DebruijnIndex::from_usize( - self.universe_indices.len() - index + self.current_index.as_usize() - 1, - ); - ty::Const::new_bound(self.infcx.tcx, db, *replace_var) - } - None => { - if ct.has_infer() { - ct.super_fold_with(self) - } else { - ct - } - } - } - } else { - ct.super_fold_with(self) - } - } -} - pub fn sizedness_fast_path<'tcx>( tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, From dbba04e0321124bdced208e9b2872c2b3eaa1786 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Tue, 21 Apr 2026 14:35:40 +0800 Subject: [PATCH 2/6] use the new routine to eagerly normalize --- .../src/type_check/canonical.rs | 70 +------------------ compiler/rustc_borrowck/src/type_check/mod.rs | 2 +- compiler/rustc_hir_analysis/src/autoderef.rs | 32 ++------- .../src/coherence/orphan.rs | 11 --- compiler/rustc_hir_typeck/src/coercion.rs | 17 ----- compiler/rustc_hir_typeck/src/method/probe.rs | 17 ++--- .../traits/fulfillment_errors.rs | 22 ++---- .../rustc_trait_selection/src/traits/mod.rs | 7 +- .../src/traits/normalize.rs | 2 +- .../src/traits/query/type_op/mod.rs | 7 +- .../src/traits/query/type_op/normalize.rs | 11 ++- compiler/rustc_ty_utils/src/ty.rs | 10 +-- 12 files changed, 44 insertions(+), 164 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 9bd6edc6b01a8..9c8093d793c35 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -8,9 +8,7 @@ use rustc_middle::mir::{Body, ConstraintCategory}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Unnormalized, Upcast}; use rustc_span::Span; use rustc_span::def_id::DefId; -use rustc_trait_selection::solve::NoSolution; use rustc_trait_selection::traits::ObligationCause; -use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp; use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput}; use tracing::{debug, instrument}; @@ -242,71 +240,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { body.source.def_id().expect_local(), ); - if self.infcx.next_trait_solver() { - let param_env = self.infcx.param_env; - // FIXME: Make this into a real type op? - self.fully_perform_op( - location.to_locations(), - ConstraintCategory::Boring, - CustomTypeOp::new( - |ocx| { - let structurally_normalize = |ty| { - ocx.structurally_normalize_ty(&cause, param_env, Unnormalized::new_wip(ty)) - .unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR")) - }; - - let tail = tcx.struct_tail_raw( - ty, - &cause, - structurally_normalize, - || {}, - ); - - Ok(tail) - }, - "normalizing struct tail", - ), - ) - .unwrap_or_else(|guar| Ty::new_error(tcx, guar)) - } else { - let mut normalize = |ty| self.normalize(ty, location); - let tail = tcx.struct_tail_raw(ty, &cause, &mut normalize, || {}); - normalize(tail) - } - } - - #[instrument(skip(self), level = "debug")] - pub(super) fn structurally_resolve( - &mut self, - ty: Ty<'tcx>, - location: impl NormalizeLocation, - ) -> Ty<'tcx> { - if self.infcx.next_trait_solver() { - let body = self.body; - let param_env = self.infcx.param_env; - // FIXME: Make this into a real type op? - self.fully_perform_op( - location.to_locations(), - ConstraintCategory::Boring, - CustomTypeOp::new( - |ocx| { - ocx.structurally_normalize_ty( - &ObligationCause::misc( - location.to_locations().span(body), - body.source.def_id().expect_local(), - ), - param_env, - Unnormalized::new_wip(ty), - ) - .map_err(|_| NoSolution) - }, - "normalizing struct tail", - ), - ) - .unwrap_or_else(|guar| Ty::new_error(self.tcx(), guar)) - } else { - self.normalize(ty, location) - } + let mut normalize = |ty| self.normalize(ty, location); + let tail = tcx.struct_tail_raw(ty, &cause, &mut normalize, || {}); + normalize(tail) } #[instrument(skip(self), level = "debug")] diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 59874e82e920f..e93fc3cac60b5 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -461,7 +461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let projected_ty = curr_projected_ty.projection_ty_core( tcx, proj, - |ty| self.structurally_resolve(ty, locations), + |ty| self.normalize(ty, locations), |ty, variant_index, field, ()| PlaceTy::field_ty(tcx, ty, variant_index, field), |_| unreachable!(), ); diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index c5ab585b19587..1637f022a4a78 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -87,19 +87,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> { let (kind, new_ty) = if let Some(ty) = self.state.cur_ty.builtin_deref(self.include_raw_pointers) { debug_assert_eq!(ty, self.infcx.resolve_vars_if_possible(ty)); - // NOTE: we may still need to normalize the built-in deref in case - // we have some type like `&::Assoc`, since users of - // autoderef expect this type to have been structurally normalized. - if self.infcx.next_trait_solver() - && let ty::Alias(..) = ty.kind() - { - let (normalized_ty, obligations) = - self.structurally_normalize_ty(Unnormalized::new_wip(ty))?; - self.state.obligations.extend(obligations); - (AutoderefKind::Builtin, normalized_ty) - } else { - (AutoderefKind::Builtin, ty) - } + (AutoderefKind::Builtin, ty) } else if let Some(ty) = self.overloaded_deref_ty(self.state.cur_ty) { // The overloaded deref check already normalizes the pointee type. (AutoderefKind::Overloaded, ty) @@ -177,9 +165,8 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { return None; } - let (normalized_ty, obligations) = self.structurally_normalize_ty(Unnormalized::new( - Ty::new_projection(tcx, trait_target_def_id, [ty]), - ))?; + let (normalized_ty, obligations) = self + .normalize_ty(Unnormalized::new(Ty::new_projection(tcx, trait_target_def_id, [ty])))?; debug!("overloaded_deref_ty({:?}) = ({:?}, {:?})", ty, normalized_ty, obligations); self.state.obligations.extend(obligations); @@ -187,25 +174,18 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { } #[instrument(level = "debug", skip(self), ret)] - pub fn structurally_normalize_ty( + pub fn normalize_ty( &self, ty: Unnormalized<'tcx, Ty<'tcx>>, ) -> Option<(Ty<'tcx>, PredicateObligations<'tcx>)> { let ocx = ObligationCtxt::new(self.infcx); - let Ok(normalized_ty) = ocx.structurally_normalize_ty( + let normalized_ty = ocx.normalize( &traits::ObligationCause::misc(self.span, self.body_id), self.param_env, ty, - ) else { - // We shouldn't have errors here in the old solver, except for - // evaluate/fulfill mismatches, but that's not a reason for an ICE. - return None; - }; + ); let errors = ocx.try_evaluate_obligations(); if !errors.is_empty() { - if self.infcx.next_trait_solver() { - unreachable!(); - } // We shouldn't have errors here in the old solver, except for // evaluate/fulfill mismatches, but that's not a reason for an ICE. debug!(?errors, "encountered errors while fulfilling"); diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 233f3798ce2b8..bacc1f1549973 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -315,17 +315,6 @@ fn orphan_check<'tcx>( return Ok(user_ty); } - let ty = if infcx.next_trait_solver() { - ocx.structurally_normalize_ty( - &cause, - ty::ParamEnv::empty(), - Unnormalized::new_wip(infcx.resolve_vars_if_possible(ty)), - ) - .unwrap_or(ty) - } else { - ty - }; - Ok::<_, !>(ty) }; diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 0a13d6c97e7c3..669bceab1cbe5 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1099,23 +1099,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Make sure to structurally resolve the types, since we use // the `TyKind`s heavily in coercion. let ocx = ObligationCtxt::new(self); - let structurally_resolve = |ty| { - let ty = self.shallow_resolve(ty); - if self.next_trait_solver() - && let ty::Alias(..) = ty.kind() - { - ocx.structurally_normalize_ty(&cause, self.param_env, Unnormalized::new_wip(ty)) - } else { - Ok(ty) - } - }; - let Ok(expr_ty) = structurally_resolve(expr_ty) else { - return false; - }; - let Ok(target_ty) = structurally_resolve(target_ty) else { - return false; - }; - let Ok(ok) = coerce.coerce(expr_ty, target_ty) else { return false; }; diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index d5e06faa6917a..4258896deec70 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -2112,21 +2112,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // `WhereClauseCandidate` requires that the self type is a param, // because it has special behavior with candidate preference as an // inherent pick. - match ocx.structurally_normalize_ty( + let ty = ocx.normalize( cause, self.param_env, Unnormalized::new_wip(trait_ref.self_ty()), - ) { - Ok(ty) => { - if !matches!(ty.kind(), ty::Param(_)) { - debug!("--> not a param ty: {xform_self_ty:?}"); - return ProbeResult::NoMatch; - } - } - Err(errors) => { - debug!("--> cannot relate self-types {:?}", errors); - return ProbeResult::NoMatch; - } + ); + if !matches!(ty.kind(), ty::Param(_)) { + debug!("--> not a param ty: {xform_self_ty:?}"); + return ProbeResult::NoMatch; } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index c46c042c886f7..785118bc6d7eb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1586,13 +1586,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |alias_term: ty::AliasTerm<'tcx>, expected_term: ty::Term<'tcx>| { let ocx = ObligationCtxt::new(self); - let Ok(normalized_term) = ocx.structurally_normalize_term( + let normalized_term = ocx.normalize( &ObligationCause::dummy(), obligation.param_env, Unnormalized::new_wip(alias_term.to_term(self.tcx)), - ) else { - return None; - }; + ); if let Err(terr) = ocx.eq( &ObligationCause::dummy(), @@ -2859,13 +2857,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); let trait_ref = normalized_predicate.trait_ref; - let Ok(assume) = ocx.structurally_normalize_const( + let assume = ocx.normalize( &obligation.cause, obligation.param_env, Unnormalized::new_wip(trait_ref.args.const_at(2)), - ) else { - return (obligation.clone(), trait_predicate); - }; + ); let Some(assume) = rustc_transmute::Assume::from_const(self.tcx, assume) else { return (obligation.clone(), trait_predicate); @@ -2912,17 +2908,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); let ocx = ObligationCtxt::new(self); - let Ok(assume) = ocx.structurally_normalize_const( + let assume = ocx.normalize( &obligation.cause, obligation.param_env, Unnormalized::new_wip(trait_pred.trait_ref.args.const_at(2)), - ) else { - self.dcx().span_delayed_bug( - span, - "Unable to construct rustc_transmute::Assume where it was previously possible", - ); - return GetSafeTransmuteErrorAndReason::Silent; - }; + ); let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else { self.dcx().span_delayed_bug( diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0196b8bee7cca..e0eeca23c6d46 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -258,7 +258,11 @@ fn do_normalize_predicates<'tcx>( elaborated_env: ty::ParamEnv<'tcx>, predicates: Vec>, ) -> Result>, ErrorGuaranteed> { - let span = cause.span; + // Even if we move back to eager normalization elsewhere, + // param env normalization remains lazy in the next solver. + if tcx.next_trait_solver_globally() { + return Ok(predicates); + } // FIXME. We should really... do something with these region // obligations. But this call just continues the older @@ -273,6 +277,7 @@ fn do_normalize_predicates<'tcx>( // by wfcheck anyway, so I'm not sure we have to check // them here too, and we will remove this function when // we move over to lazy normalization *anyway*. + let span = cause.span; let infcx = tcx.infer_ctxt().ignoring_regions().build(TypingMode::non_body_analysis()); let ocx = ObligationCtxt::new_with_diagnostics(&infcx); let predicates = ocx.normalize(&cause, elaborated_env, Unnormalized::new_wip(predicates)); diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index 26360c3972e37..2946d8d1d487d 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -32,11 +32,11 @@ impl<'tcx> At<'_, 'tcx> { &self, value: Unnormalized<'tcx, T>, ) -> InferOk<'tcx, T> { - let value = value.skip_normalization(); if self.infcx.next_trait_solver() { let Normalized { value, obligations } = crate::solve::normalize(*self, value); InferOk { value, obligations } } else { + let value = value.skip_normalization(); let mut selcx = SelectionContext::new(self.infcx); let Normalized { value, obligations } = normalize_with_depth(&mut selcx, self.param_env, self.cause.clone(), 0, value); diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs index ea062db3128ab..b2c1f9a5eed14 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs @@ -158,7 +158,12 @@ where root_def_id, "query type op", span, - |ocx| QueryTypeOp::perform_locally_with_next_solver(ocx, self, span), + |ocx| { + if let Some(result) = QueryTypeOp::try_fast_path(infcx.tcx, &self) { + return Ok(result); + } + QueryTypeOp::perform_locally_with_next_solver(ocx, self, span) + }, )? .0); } diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs index 1b8a02f78b579..577a5564c6312 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs @@ -29,11 +29,16 @@ where } fn perform_locally_with_next_solver( - _ocx: &ObligationCtxt<'_, 'tcx>, + ocx: &ObligationCtxt<'_, 'tcx>, key: ParamEnvAnd<'tcx, Self>, - _span: Span, + span: Span, ) -> Result { - Ok(key.value.value) + ocx.deeply_normalize( + &ObligationCause::dummy_with_span(span), + key.param_env, + Unnormalized::new_wip(key.value.value), + ) + .map_err(|_| NoSolution) } } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index cb08ca0757876..258b9db60960d 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -362,14 +362,8 @@ fn impl_self_is_guaranteed_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_def_id: DefId) tcx.type_of(impl_def_id).instantiate_identity().skip_norm_wip(), &cause, |ty| { - ocx.structurally_normalize_ty(&cause, param_env, Unnormalized::new_wip(ty)) - .unwrap_or_else(|_| { - Ty::new_error_with_message( - tcx, - tcx.def_span(impl_def_id), - "struct tail should be computable", - ) - }) + // FIXME: ambiguity is just ignored. + ocx.normalize(&cause, param_env, Unnormalized::new_wip(ty)) }, || (), ); From c50bbc2b888e57ae1132e59a1b1f38f9baac9f63 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Fri, 24 Apr 2026 16:40:53 +0800 Subject: [PATCH 3/6] remove try_structurally_resolve_type --- compiler/rustc_hir_typeck/src/_match.rs | 3 +- compiler/rustc_hir_typeck/src/callee.rs | 5 +-- compiler/rustc_hir_typeck/src/cast.rs | 6 +-- compiler/rustc_hir_typeck/src/closure.rs | 9 ++--- compiler/rustc_hir_typeck/src/coercion.rs | 14 ++----- compiler/rustc_hir_typeck/src/demand.rs | 6 +-- compiler/rustc_hir_typeck/src/expectation.rs | 3 +- compiler/rustc_hir_typeck/src/expr.rs | 18 ++++----- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 39 +------------------ .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 23 ----------- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 16 +------- compiler/rustc_hir_typeck/src/inline_asm.rs | 8 ++-- compiler/rustc_hir_typeck/src/pat.rs | 16 ++++---- 13 files changed, 41 insertions(+), 125 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 4e0ea8daff333..bc155dc67c233 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -60,8 +60,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // type in that case) let mut all_arms_diverge = Diverges::WarnedAlways; - let expected = - orig_expected.try_structurally_resolve_and_adjust_for_branches(self, expr.span); + let expected = orig_expected.try_structurally_resolve_and_adjust_for_branches(self); debug!(?expected); let mut coercion = { diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index e5fcc68dad23a..fc504116101c9 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -79,7 +79,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => self.check_expr(callee_expr), }; - let expr_ty = self.try_structurally_resolve_type(call_expr.span, original_callee_ty); + let expr_ty = self.resolve_vars_with_obligations(original_callee_ty); let mut autoderef = self.autoderef(callee_expr.span, expr_ty); let mut result = None; @@ -211,8 +211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_exprs: &'tcx [hir::Expr<'tcx>], autoderef: &Autoderef<'a, 'tcx>, ) -> Option> { - let adjusted_ty = - self.try_structurally_resolve_type(autoderef.span(), autoderef.final_ty()); + let adjusted_ty = self.resolve_vars_with_obligations(autoderef.final_ty()); // If the callee is a function pointer or a closure, then we're all set. match *adjusted_ty.kind() { diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 93275f62dcc17..6642038455489 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -102,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ok(Some(PointerKind::Thin)); } - let t = self.try_structurally_resolve_type(span, t); + let t = self.resolve_vars_with_obligations(t); Ok(match *t.kind() { ty::Slice(_) | ty::Str => Some(PointerKind::Length), @@ -1041,8 +1041,8 @@ impl<'a, 'tcx> CastCheck<'tcx> { mut m_cast: ty::TypeAndMut<'tcx>, ) -> Result> { // array-ptr-cast: allow mut-to-mut, mut-to-const, const-to-const - m_expr.ty = fcx.try_structurally_resolve_type(self.expr_span, m_expr.ty); - m_cast.ty = fcx.try_structurally_resolve_type(self.cast_span, m_cast.ty); + m_expr.ty = fcx.resolve_vars_with_obligations(m_expr.ty); + m_cast.ty = fcx.resolve_vars_with_obligations(m_cast.ty); if m_expr.mutbl >= m_cast.mutbl && let ty::Array(ety, _) = m_expr.ty.kind() diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 5a241ca846c3e..763d2a27e6cc0 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -59,10 +59,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // closure sooner rather than later, so first examine the expected // type, and see if can glean a closure kind from there. let (expected_sig, expected_kind) = match expected.to_option(self) { - Some(ty) => self.deduce_closure_signature( - self.try_structurally_resolve_type(expr_span, ty), - closure.kind, - ), + Some(ty) => { + self.deduce_closure_signature(self.resolve_vars_with_obligations(ty), closure.kind) + } None => (None, None), }; @@ -963,7 +962,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let closure_span = self.tcx.def_span(body_def_id); let ret_ty = ret_coercion.borrow().expected_ty(); - let ret_ty = self.try_structurally_resolve_type(closure_span, ret_ty); + let ret_ty = self.resolve_vars_with_obligations(ret_ty); let get_future_output = |predicate: ty::Predicate<'tcx>, span| { // Search for a pending obligation like diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 669bceab1cbe5..abd5f38f0ed08 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1051,17 +1051,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &'tcx hir::Expr<'tcx>, expr_ty: Ty<'tcx>, - mut target: Ty<'tcx>, + target: Ty<'tcx>, allow_two_phase: AllowTwoPhase, cause: Option>, ) -> RelateResult<'tcx, Ty<'tcx>> { - let source = self.try_structurally_resolve_type(expr.span, expr_ty); - if self.next_trait_solver() { - target = self.try_structurally_resolve_type( - cause.as_ref().map_or(expr.span, |cause| cause.span), - target, - ); - } + let source = self.resolve_vars_with_obligations(expr_ty); debug!("coercion::try({:?}: {:?} -> {:?})", expr, source, target); let cause = @@ -1244,8 +1238,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { new: &hir::Expr<'_>, new_ty: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> { - let prev_ty = self.try_structurally_resolve_type(cause.span, prev_ty); - let new_ty = self.try_structurally_resolve_type(new.span, new_ty); + let prev_ty = self.resolve_vars_with_obligations(prev_ty); + let new_ty = self.resolve_vars_with_obligations(new_ty); debug!( "coercion::try_find_coercion_lub({:?}, {:?}, exprs={:?} exprs)", prev_ty, diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 29fc6729e4b3e..5454b282d5226 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -260,11 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { mut expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, allow_two_phase: AllowTwoPhase, ) -> Result, Diag<'a>> { - let expected = if self.next_trait_solver() { - expected - } else { - self.resolve_vars_with_obligations(expected) - }; + let expected = self.resolve_vars_with_obligations(expected); let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) { Ok(ty) => return Ok(ty), diff --git a/compiler/rustc_hir_typeck/src/expectation.rs b/compiler/rustc_hir_typeck/src/expectation.rs index 2fbea5b61cfc6..bdbddd4bebec9 100644 --- a/compiler/rustc_hir_typeck/src/expectation.rs +++ b/compiler/rustc_hir_typeck/src/expectation.rs @@ -43,11 +43,10 @@ impl<'a, 'tcx> Expectation<'tcx> { pub(super) fn try_structurally_resolve_and_adjust_for_branches( &self, fcx: &FnCtxt<'a, 'tcx>, - span: Span, ) -> Expectation<'tcx> { match *self { ExpectHasType(ety) => { - let ety = fcx.try_structurally_resolve_type(span, ety); + let ety = fcx.resolve_vars_with_obligations(ety); if !ety.is_ty_var() { ExpectHasType(ety) } else { NoExpectation } } ExpectRvalueLikeUnsized(ety) => ExpectRvalueLikeUnsized(ety), diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 664c3c457876c..fd9c1bc8780ee 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -82,7 +82,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // While we don't allow *arbitrary* coercions here, we *do* allow // coercions from ! to `expected`. - if self.try_structurally_resolve_type(expr.span, ty).is_never() + if self.resolve_vars_with_obligations(ty).is_never() && self.tcx.expr_guaranteed_to_constitute_read_for_never(expr) { if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // unless it's a place expression that isn't being read from, in which case // diverging would be unsound since we may never actually read the `!`. // e.g. `let _ = *never_ptr;` with `never_ptr: *const !`. - if self.try_structurally_resolve_type(expr.span, ty).is_never() + if self.resolve_vars_with_obligations(ty).is_never() && self.tcx.expr_guaranteed_to_constitute_read_for_never(expr) { self.diverges.set(self.diverges.get() | Diverges::always(expr.span)); @@ -454,7 +454,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { - match self.try_structurally_resolve_type(expr.span, ty).kind() { + match self.resolve_vars_with_obligations(ty).kind() { ty::Ref(_, ty, _) | ty::RawPtr(ty, _) => { if oprnd.is_syntactic_place_expr() { // Places may legitimately have unsized types. @@ -1187,7 +1187,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let cond_diverges = self.diverges.get(); self.diverges.set(Diverges::Maybe); - let expected = orig_expected.try_structurally_resolve_and_adjust_for_branches(self, sp); + let expected = orig_expected.try_structurally_resolve_and_adjust_for_branches(self); let then_ty = self.check_expr_with_expectation(then_expr, expected); let then_diverges = self.diverges.get(); self.diverges.set(Diverges::Maybe); @@ -1457,7 +1457,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Expectation<'tcx>, ) -> Ty<'tcx> { let rcvr_t = self.check_expr(rcvr); - let rcvr_t = self.try_structurally_resolve_type(rcvr.span, rcvr_t); + let rcvr_t = self.resolve_vars_with_obligations(rcvr_t); match self.lookup_method(rcvr_t, segment, segment.ident.span, expr, rcvr, args) { Ok(method) => { @@ -1644,11 +1644,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let coerce_to = expected .to_option(self) .and_then(|uty| { - self.try_structurally_resolve_type(expr.span, uty) + self.resolve_vars_with_obligations(uty) .builtin_index() // Avoid using the original type variable as the coerce_to type, as it may resolve // during the first coercion instead of being the LUB type. - .filter(|t| !self.try_structurally_resolve_type(expr.span, *t).is_ty_var()) + .filter(|t| !self.resolve_vars_with_obligations(*t).is_ty_var()) }) .unwrap_or_else(|| self.next_ty_var(expr.span)); let mut coerce = CoerceMany::with_capacity(coerce_to, args.len()); @@ -1773,7 +1773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let mut expectations = expected .only_has_type(self) - .and_then(|ty| self.try_structurally_resolve_type(expr.span, ty).opt_tuple_fields()) + .and_then(|ty| self.resolve_vars_with_obligations(ty).opt_tuple_fields()) .unwrap_or_default() .iter(); @@ -1847,7 +1847,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let tcx = self.tcx; - let adt_ty = self.try_structurally_resolve_type(path_span, adt_ty); + let adt_ty = self.resolve_vars_with_obligations(adt_ty); let adt_ty_hint = expected.only_has_type(self).and_then(|expected| { self.fudge_inference_if_ok(|| { let ocx = ObligationCtxt::new(self); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 9a54d651fe73a..4d118db5c9eb9 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -470,13 +470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let tail = self.tcx.struct_tail_raw( ty, &self.misc(span), - |ty| { - if self.next_trait_solver() { - self.try_structurally_resolve_type(span, ty) - } else { - self.normalize(span, Unnormalized::new_wip(ty)) - } - }, + |ty| self.normalize(span, Unnormalized::new_wip(ty)), || {}, ); // Sized types have static alignment, and so do slices. @@ -1432,35 +1426,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - /// Try to resolve `ty` to a structural type, normalizing aliases. - /// - /// In case there is still ambiguity, the returned type may be an inference - /// variable. This is different from `structurally_resolve_type` which errors - /// in this case. - #[instrument(level = "debug", skip(self, sp), ret)] - pub(crate) fn try_structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> { - if self.next_trait_solver() - && let ty::Alias(..) = ty.kind() - { - // We need to use a separate variable here as otherwise the temporary for - // `self.fulfillment_cx.borrow_mut()` is alive in the `Err` branch, resulting - // in a reentrant borrow, causing an ICE. - let result = self.at(&self.misc(sp), self.param_env).structurally_normalize_ty( - Unnormalized::new_wip(ty), - &mut **self.fulfillment_cx.borrow_mut(), - ); - match result { - Ok(normalized_ty) => normalized_ty, - Err(errors) => { - let guar = self.err_ctxt().report_fulfillment_errors(errors); - return Ty::new_error(self.tcx, guar); - } - } - } else { - self.resolve_vars_with_obligations(ty) - } - } - #[instrument(level = "debug", skip(self, sp), ret)] pub(crate) fn try_structurally_resolve_const( &self, @@ -1502,7 +1467,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// If no resolution is possible, then an error is reported. /// Numeric inference variables may be left unresolved. pub(crate) fn structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> { - let ty = self.try_structurally_resolve_type(sp, ty); + let ty = self.resolve_vars_with_obligations(ty); if !ty.is_ty_var() { ty } else { self.type_must_be_known_at_this_point(sp, ty) } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 6a14ab9683bf1..e500207d6da19 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -218,29 +218,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_place_expr_if_unsized(fn_input_ty, arg_expr); } - let formal_input_tys_ns; - let formal_input_tys = if self.next_trait_solver() { - // In the new solver, the normalizations are done lazily. - // Because of this, if we encounter unnormalized alias types inside this - // fudge scope, we might lose the relationships between them and other vars - // when fudging inference variables created here. - // So, we utilize generalization to normalize aliases by adding a new - // inference var and equating it with the type we want to pull out of the - // fudge scope. - formal_input_tys_ns = formal_input_tys - .iter() - .map(|&ty| { - let generalized_ty = self.next_ty_var(call_span); - self.demand_eqtype(call_span, ty, generalized_ty); - generalized_ty - }) - .collect_vec(); - - formal_input_tys_ns.as_slice() - } else { - formal_input_tys - }; - // First, let's unify the formal method signature with the expectation eagerly. // We use this to guide coercion inference; it's output is "fudged" which means // any remaining type variables are assigned to new, unrelated variables. This diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index d9c63c41a67c1..63bd49f080309 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -411,11 +411,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> { kind: ty::Projection { .. } | ty::Inherent { .. } | ty::Free { .. }, .. }) if !ty.has_escaping_bound_vars() => { - if self.next_trait_solver() { - self.try_structurally_resolve_type(span, ty).ty_adt_def() - } else { - self.normalize(span, Unnormalized::new_wip(ty)).ty_adt_def() - } + self.normalize(span, Unnormalized::new_wip(ty)).ty_adt_def() } _ => None, } @@ -485,15 +481,7 @@ pub(crate) struct LoweredTy<'tcx> { impl<'tcx> LoweredTy<'tcx> { fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> { - // FIXME(-Znext-solver=no): This is easier than requiring all uses of `LoweredTy` - // to call `try_structurally_resolve_type` instead. This seems like a lot of - // effort, especially as we're still supporting the old solver. We may revisit - // this in the future. - let normalized = if fcx.next_trait_solver() { - fcx.try_structurally_resolve_type(span, raw) - } else { - fcx.normalize(span, Unnormalized::new_wip(raw)) - }; + let normalized = fcx.normalize(span, Unnormalized::new_wip(raw)); LoweredTy { raw, normalized } } } diff --git a/compiler/rustc_hir_typeck/src/inline_asm.rs b/compiler/rustc_hir_typeck/src/inline_asm.rs index 23f07b1734fda..1e11b801923b0 100644 --- a/compiler/rustc_hir_typeck/src/inline_asm.rs +++ b/compiler/rustc_hir_typeck/src/inline_asm.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { fn expr_ty(&self, expr: &hir::Expr<'tcx>) -> Ty<'tcx> { let ty = self.fcx.typeck_results.borrow().expr_ty_adjusted(expr); - let ty = self.fcx.try_structurally_resolve_type(expr.span, ty); + let ty = self.fcx.resolve_vars_with_obligations(ty); if ty.has_non_region_infer() { Ty::new_misc_error(self.tcx()) } else { @@ -53,13 +53,13 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { } // FIXME(compiler-errors): This could use `<$ty as Pointee>::Metadata == ()` - fn is_thin_ptr_ty(&self, span: Span, ty: Ty<'tcx>) -> bool { + fn is_thin_ptr_ty(&self, ty: Ty<'tcx>) -> bool { // Type still may have region variables, but `Sized` does not depend // on those, so just erase them before querying. if self.fcx.type_is_sized_modulo_regions(self.fcx.param_env, ty) { return true; } - if let ty::Foreign(..) = self.fcx.try_structurally_resolve_type(span, ty).kind() { + if let ty::Foreign(..) = self.fcx.resolve_vars_with_obligations(ty).kind() { return true; } false @@ -90,7 +90,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { ty::Float(FloatTy::F128) => Ok(InlineAsmType::F128), ty::FnPtr(..) => Ok(asm_ty_isize), ty::RawPtr(elem_ty, _) => { - if self.is_thin_ptr_ty(span, elem_ty) { + if self.is_thin_ptr_ty(elem_ty) { Ok(asm_ty_isize) } else { Err(NonAsmTypeReason::NotSizedPtr(ty)) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index d7f15222376c8..67914ee136fb2 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -497,7 +497,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected = if let AdjustMode::Peel { .. } = adjust_mode && pat.default_binding_modes { - self.try_structurally_resolve_type(pat.span, expected) + self.resolve_vars_with_obligations(expected) } else { expected }; @@ -816,7 +816,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut peeled_ty = lit_ty; let mut pat_ref_layers = 0; while let ty::Ref(_, inner_ty, mutbl) = - *self.try_structurally_resolve_type(pat.span, peeled_ty).kind() + *self.resolve_vars_with_obligations(peeled_ty).kind() { // We rely on references at the head of constants being immutable. debug_assert!(mutbl.is_not()); @@ -962,7 +962,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match *expected.kind() { // Allow `b"...": &[u8]` ty::Ref(_, inner_ty, _) - if self.try_structurally_resolve_type(span, inner_ty).is_slice() => + if self.resolve_vars_with_obligations(inner_ty).is_slice() => { trace!(?expr.hir_id.local_id, "polymorphic byte string lit"); pat_ty = Ty::new_imm_ref( @@ -991,7 +991,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // string literal patterns to have type `str`. This is accounted for when lowering to MIR. if self.tcx.features().deref_patterns() && matches!(lit_kind, ast::LitKind::Str(..)) - && self.try_structurally_resolve_type(span, expected).is_str() + && self.resolve_vars_with_obligations(expected).is_str() { pat_ty = self.tcx.types.str_; } @@ -1032,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // be peeled to `str` while ty here is still `&str`, if we don't // err early here, a rather confusing unification error will be // emitted instead). - let ty = self.try_structurally_resolve_type(expr.span, ty); + let ty = self.resolve_vars_with_obligations(ty); let fail = !(ty.is_numeric() || ty.is_char() || ty.is_ty_var() || ty.references_error()); Some((fail, ty, expr.span)) @@ -2705,7 +2705,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { [source_ty], ); let target_ty = self.normalize(span, Unnormalized::new_wip(target_ty)); - self.try_structurally_resolve_type(span, target_ty) + self.resolve_vars_with_obligations(target_ty) } /// Check if the interior of a deref pattern (either explicit or implicit) has any `ref mut` @@ -2753,7 +2753,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat_info.max_ref_mutbl = pat_info.max_ref_mutbl.cap_to_weakly_not(pat_prefix_span); } - expected = self.try_structurally_resolve_type(pat.span, expected); + expected = self.resolve_vars_with_obligations(expected); // Determine whether we're consuming an inherited reference and resetting the default // binding mode, based on edition and enabled experimental features. if let ByRef::Yes(inh_pin, inh_mut) = pat_info.binding_mode @@ -3044,7 +3044,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, pat_info: PatInfo<'tcx>, ) -> Ty<'tcx> { - let expected = self.try_structurally_resolve_type(span, expected); + let expected = self.resolve_vars_with_obligations(expected); // If the pattern is irrefutable and `expected` is an infer ty, we try to equate it // to an array if the given pattern allows it. See issue #76342 From 4767f23f58155cd17856d31e43917eaefee5e341 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 12:05:33 +0800 Subject: [PATCH 4/6] remove `normalize_capture_place` --- compiler/rustc_hir_typeck/src/upvar.rs | 51 +++----------------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 04b548ce0e9f0..dfdc7c3d8df0a 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -49,9 +49,7 @@ use rustc_middle::ty::{ use rustc_middle::{bug, span_bug}; use rustc_session::lint; use rustc_span::{BytePos, Pos, Span, Symbol, sym}; -use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _; use rustc_trait_selection::infer::InferCtxtExt; -use rustc_trait_selection::solve; use tracing::{debug, instrument}; use super::FnCtxt; @@ -1172,45 +1170,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } } - fn normalize_capture_place(&self, span: Span, place: Place<'tcx>) -> Place<'tcx> { - let mut place = self.resolve_vars_if_possible(place); - - // In the new solver, types in HIR `Place`s can contain unnormalized aliases, - // which can ICE later (e.g. when projecting fields for diagnostics). - if self.next_trait_solver() { - let cause = self.misc(span); - let at = self.at(&cause, self.param_env); - match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals( - at, - Unnormalized::new_wip(place.clone()), - vec![], - ) { - Ok((normalized, goals)) => { - if !goals.is_empty() { - let mut typeck_results = self.typeck_results.borrow_mut(); - typeck_results.coroutine_stalled_predicates.extend( - goals - .into_iter() - // FIXME: throwing away the param-env :( - .map(|goal| (goal.predicate, self.misc(span))), - ); - } - normalized - } - Err(errors) => { - let guar = self.infcx.err_ctxt().report_fulfillment_errors(errors); - place.base_ty = Ty::new_error(self.tcx, guar); - for proj in &mut place.projections { - proj.ty = Ty::new_error(self.tcx, guar); - } - place - } - } - } else { - // For the old solver we can rely on `normalize` to eagerly normalize aliases. - self.normalize(span, Unnormalized::new_wip(place)) - } - } /// Combines all the reasons for 2229 migrations fn compute_2229_migrations_reasons( @@ -1828,7 +1787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Normalize eagerly when inserting into `capture_information`, so all downstream // capture analysis can assume a normalized `Place`. - self.normalize_capture_place(self.tcx.hir_span(var_hir_id), place) + self.normalize(self.tcx.hir_span(var_hir_id), Unnormalized::new_wip(place)) } fn should_log_capture_analysis(&self, closure_def_id: LocalDefId) -> bool { @@ -2134,7 +2093,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { let dummy_capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable); let span = self.fcx.tcx.hir_span(diag_expr_id); - let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone()); + let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone())); let (place, _) = restrict_capture_precision(place, dummy_capture_kind); @@ -2148,7 +2107,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { assert_eq!(self.closure_def_id, upvar_id.closure_expr_id); let span = self.fcx.tcx.hir_span(diag_expr_id); - let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone()); + let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone())); self.capture_information.push(( place, @@ -2166,7 +2125,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { assert_eq!(self.closure_def_id, upvar_id.closure_expr_id); let span = self.fcx.tcx.hir_span(diag_expr_id); - let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone()); + let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone())); self.capture_information.push(( place, @@ -2192,7 +2151,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { let capture_kind = ty::UpvarCapture::ByRef(bk); let span = self.fcx.tcx.hir_span(diag_expr_id); - let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone()); + let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone())); // We only want repr packed restriction to be applied to reading references into a packed // struct, and not when the data is being moved. Therefore we call this method here instead From 1c1372c908a50e0ff077b2a7e1c3eae9c023ed75 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Tue, 21 Apr 2026 15:34:28 +0800 Subject: [PATCH 5/6] bless diagnostics change --- ...rent-assoc-ty-mismatch-issue-153539.stderr | 5 +- ...opaque-inherent-fn-ptr-issue-155204.stderr | 9 +-- .../next-solver-opaque-inherent-no-ice.stderr | 9 +-- .../associated-types-coherence-failure.stderr | 8 +-- ...ram-env-shadowing-incompatible-args.stderr | 2 +- tests/ui/coherence/coherence-with-closure.rs | 2 +- .../coherence/coherence-with-closure.stderr | 4 +- .../ui/coherence/coherence-with-coroutine.rs | 2 +- .../coherence-with-coroutine.stock.stderr | 4 +- .../ui/coherence/normalize-for-errors.stderr | 4 +- .../unevaluated-const-ice-119731.rs | 9 +-- .../unevaluated-const-ice-119731.stderr | 32 ++-------- tests/ui/delegation/unsupported.next.stderr | 12 +++- .../as_expression.next.stderr | 16 +---- .../do_not_recommend/as_expression.rs | 1 - ...st-prove-where-clauses-on-norm.next.stderr | 8 +-- .../must-prove-where-clauses-on-norm.rs | 2 +- ...nsubstituting-in-region-112823.next.stderr | 16 +---- ...-type-whensubstituting-in-region-112823.rs | 4 +- .../in-trait/alias-bounds-when-not-wf.rs | 6 +- .../in-trait/alias-bounds-when-not-wf.stderr | 18 +----- ...nference-constraints-from-blanket-3.stderr | 17 +++-- .../ice-issue-146191.current.stderr | 2 +- .../ice-issue-146191.next.stderr | 6 +- .../non-defining-uses/ice-issue-146191.rs | 2 +- .../recursive-in-exhaustiveness.next.stderr | 6 +- .../impl-trait/recursive-in-exhaustiveness.rs | 2 +- .../two_tait_defining_each_other2.next.stderr | 4 +- .../impl-trait/unsized_coercion.next.stderr | 12 +++- tests/ui/impl-trait/unsized_coercion.rs | 1 + .../impl-trait/unsized_coercion3.next.stderr | 16 ++++- .../impl-trait/unsized_coercion3.old.stderr | 2 +- tests/ui/impl-trait/unsized_coercion3.rs | 1 + tests/ui/issues/issue-33941.rs | 6 +- ...rg-type-mismatch-issue-45727.current.fixed | 5 +- ...-arg-type-mismatch-issue-45727.next.stderr | 27 +++----- .../closure-arg-type-mismatch-issue-45727.rs | 5 +- .../default-item-normalization-ambig-1.rs | 4 +- .../default-item-normalization-ambig-1.stderr | 4 +- .../next-solver-region-resolution.rs | 11 ++-- .../next-solver-region-resolution.stderr | 64 ++----------------- .../traits/next-solver/alias-bound-unsound.rs | 10 ++- .../next-solver/alias-bound-unsound.stderr | 18 +----- .../alias_eq_substs_eq_not_intercrate.stderr | 4 +- .../const-region-infer-to-static-in-binder.rs | 1 + ...st-region-infer-to-static-in-binder.stderr | 14 +++- .../coercion/non-wf-in-coerce-pointers.rs | 3 +- .../coercion/non-wf-in-coerce-pointers.stderr | 16 +---- ...trait_ref_is_knowable-norm-overflow.stderr | 3 +- ...em-bound-via-impl-where-clause.next.stderr | 26 +------- .../item-bound-via-impl-where-clause.rs | 7 +- .../cycles/unproductive-in-coherence.rs | 2 +- .../cycles/unproductive-in-coherence.stderr | 2 +- .../diagnostics/projection-trait-ref.stderr | 8 +-- .../dont-ice-on-bad-transmute-in-typeck.rs | 14 ++-- ...dont-ice-on-bad-transmute-in-typeck.stderr | 30 ++++++--- .../traits/next-solver/dyn-incompatibility.rs | 1 + .../next-solver/dyn-incompatibility.stderr | 14 +++- .../find-param-recursion-issue-152716.rs | 2 +- .../lazy-nested-obligations-2.next.stderr | 4 +- .../normalize/normalize-param-env-2.stderr | 51 +++++++++++++-- ...ction-with-unsatisfied-bound-2.next.stderr | 16 ++--- ...e_of-tait-in-defining-scope.is_send.stderr | 6 +- ..._of-tait-in-defining-scope.not_send.stderr | 6 +- .../dont-type_of-tait-in-defining-scope.rs | 2 +- .../opaques/method_autoderef_constraints.rs | 2 - .../method_autoderef_constraints.stderr | 36 ++--------- .../recursive-self-normalization-2.rs | 2 +- .../stalled-coroutine-obligations.rs | 2 - .../stalled-coroutine-obligations.stderr | 29 ++------- ...rivial-unsized-projection-2.bad_new.stderr | 17 +---- .../trivial-unsized-projection.bad_new.stderr | 17 +---- ...ned-projection-normalization-2.next.stderr | 10 +-- ...nconstrained-projection-normalization-2.rs | 1 - .../type-alias-normalization.rs | 4 +- .../type-alias-normalization.stderr | 29 --------- .../coherence/coherence_cross_crate.rs | 2 +- .../coherence/coherence_cross_crate.stderr | 4 +- .../coherence_different_hidden_ty.rs | 2 +- .../coherence_different_hidden_ty.stderr | 4 +- .../constrain_in_projection2.next.stderr | 4 +- .../generic_nondefining_use.next.stderr | 12 ++-- .../impl_trait_for_same_tait.stderr | 12 ++-- .../implied_lifetime_wf_check.error.stderr | 4 +- .../issue-84660-unsoundness.current.stderr | 2 +- .../issue-84660-unsoundness.next.stderr | 13 ++-- .../issue-84660-unsoundness.rs | 2 +- .../nested-tait-inference2.current.stderr | 2 +- .../nested-tait-inference2.next.stderr | 6 +- .../nested-tait-inference2.rs | 2 +- .../opaque-alias-relate-issue-151331.rs | 2 +- .../opaque-alias-relate-issue-151331.stderr | 11 +++- .../bad-index-due-to-nested.next.stderr | 21 +----- tests/ui/typeck/bad-index-due-to-nested.rs | 1 - 94 files changed, 336 insertions(+), 549 deletions(-) delete mode 100644 tests/ui/transmutability/type-alias-normalization.stderr diff --git a/tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr b/tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr index 74d88889223f3..9ce20cb4875b9 100644 --- a/tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr +++ b/tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr @@ -11,10 +11,7 @@ LL | fn ret_ref_local<'e>() -> &'e i32 { | ------- expected `&'e i32` because of return type ... LL | f(&1) - | ^^^^^ expected `&i32`, found associated type - | - = help: consider constraining the associated type `S<'_>::P` to `&'e i32` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + | ^^^^^ expected `&i32`, found `()` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr b/tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr index 8974ed53bc0fa..65a20433f1fba 100644 --- a/tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr +++ b/tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr @@ -46,16 +46,17 @@ LL | type AssocType = impl Send; error[E0308]: mismatched types --> $DIR/next-solver-opaque-inherent-fn-ptr-issue-155204.rs:14:9 | +LL | type AssocType = impl Send; + | --------- the expected opaque type +... LL | fn ret(&self) -> Self::AssocType { | --------------- expected `Windows fn(&'a ())>::AssocType` because of return type LL | LL | () | ^^ types differ | - = note: expected associated type `Windows fn(&'a ())>::AssocType` - found unit type `()` - = help: consider constraining the associated type `Windows fn(&'a ())>::AssocType` to `()` or calling a method that returns `Windows fn(&'a ())>::AssocType` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + = note: expected opaque type `Windows fn(&'a ())>::AssocType` + found unit type `()` error: aborting due to 7 previous errors diff --git a/tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr b/tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr index 03f369359c0d8..0f893a6d5688e 100644 --- a/tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr +++ b/tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr @@ -40,15 +40,16 @@ LL | type ImplTrait = impl Clone; error[E0308]: mismatched types --> $DIR/next-solver-opaque-inherent-no-ice.rs:13:9 | +LL | type ImplTrait = impl Clone; + | ---------- the expected opaque type +... LL | fn f() -> Self::ImplTrait { | --------------- expected `Foo::ImplTrait` because of return type LL | () | ^^ types differ | - = note: expected associated type `Foo::ImplTrait` - found unit type `()` - = help: consider constraining the associated type `Foo::ImplTrait` to `()` or calling a method that returns `Foo::ImplTrait` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + = note: expected opaque type `Foo::ImplTrait` + found unit type `()` error: aborting due to 6 previous errors diff --git a/tests/ui/associated-types/associated-types-coherence-failure.stderr b/tests/ui/associated-types/associated-types-coherence-failure.stderr index 25c22e5f82ac2..211613b371492 100644 --- a/tests/ui/associated-types/associated-types-coherence-failure.stderr +++ b/tests/ui/associated-types/associated-types-coherence-failure.stderr @@ -1,20 +1,20 @@ -error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned` +error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `Cow<'_, _>` --> $DIR/associated-types-coherence-failure.rs:21:1 | LL | impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { | ----------------------------------------------------------------------------- first implementation here ... LL | impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Cow<'_, _>` -error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned` +error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `&_` --> $DIR/associated-types-coherence-failure.rs:28:1 | LL | impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { | ----------------------------------------------------------------------------- first implementation here ... LL | impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr b/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr index c401233242489..692045dcc71c5 100644 --- a/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr +++ b/tests/ui/associated-types/suggest-param-env-shadowing-incompatible-args.stderr @@ -8,7 +8,7 @@ error[E0308]: mismatched types --> $DIR/suggest-param-env-shadowing-incompatible-args.rs:14:9 | LL | fn foo() -> Self::Assoc { - | ----------- expected `<() as Foo>::Assoc` because of return type + | ----------- expected `u8` because of return type LL | [] | ^^ expected `u8`, found `[_; 0]` | diff --git a/tests/ui/coherence/coherence-with-closure.rs b/tests/ui/coherence/coherence-with-closure.rs index ac2c55843929e..186d6db1ab5f3 100644 --- a/tests/ui/coherence/coherence-with-closure.rs +++ b/tests/ui/coherence/coherence-with-closure.rs @@ -10,6 +10,6 @@ struct Wrapper(T); trait Trait {} impl Trait for Wrapper {} impl Trait for Wrapper {} -//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper` +//~^ ERROR: conflicting implementations of trait `Trait` for type fn main() {} diff --git a/tests/ui/coherence/coherence-with-closure.stderr b/tests/ui/coherence/coherence-with-closure.stderr index 37f393ceeb70a..e1a0b5156e4f4 100644 --- a/tests/ui/coherence/coherence-with-closure.stderr +++ b/tests/ui/coherence/coherence-with-closure.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper` +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<_>` --> $DIR/coherence-with-closure.rs:12:1 | LL | impl Trait for Wrapper {} | ------------------------------------- first implementation here LL | impl Trait for Wrapper {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<_>` error: aborting due to 1 previous error diff --git a/tests/ui/coherence/coherence-with-coroutine.rs b/tests/ui/coherence/coherence-with-coroutine.rs index 0e65a6c1da031..15779345dbbd9 100644 --- a/tests/ui/coherence/coherence-with-coroutine.rs +++ b/tests/ui/coherence/coherence-with-coroutine.rs @@ -21,6 +21,6 @@ struct Wrapper(T); trait Trait {} impl Trait for Wrapper {} impl Trait for Wrapper {} -//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper` +//[stock]~^ ERROR: conflicting implementations of trait `Trait` for type fn main() {} diff --git a/tests/ui/coherence/coherence-with-coroutine.stock.stderr b/tests/ui/coherence/coherence-with-coroutine.stock.stderr index c7af384df6d30..511f6d2318feb 100644 --- a/tests/ui/coherence/coherence-with-coroutine.stock.stderr +++ b/tests/ui/coherence/coherence-with-coroutine.stock.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper` +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<_>` --> $DIR/coherence-with-coroutine.rs:23:1 | LL | impl Trait for Wrapper {} | --------------------------------------- first implementation here LL | impl Trait for Wrapper {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<_>` error: aborting due to 1 previous error diff --git a/tests/ui/coherence/normalize-for-errors.stderr b/tests/ui/coherence/normalize-for-errors.stderr index 6fbcf5b0e1aca..74a3015801d2b 100644 --- a/tests/ui/coherence/normalize-for-errors.stderr +++ b/tests/ui/coherence/normalize-for-errors.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, <_ as Iterator>::Item)` +error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, _)` --> $DIR/normalize-for-errors.rs:13:1 | LL | impl MyTrait for (T, S::Item) {} | ------------------------------------------------------ first implementation here LL | LL | impl MyTrait for (Box<<(MyType,) as Mirror>::Assoc>, S::Item) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(Box<(MyType,)>, <_ as Iterator>::Item)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(Box<(MyType,)>, _)` | = note: upstream crates may add a new impl of trait `std::clone::Clone` for type `std::boxed::Box<(MyType,)>` in future versions = note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::boxed::Box<(MyType,)>` in future versions diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs index 02a95ed3e9082..905e4ec4571db 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs @@ -26,12 +26,9 @@ mod v20 { } impl v17 { - //~^ ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} - //~| ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} - //~| ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} - //~| ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} - //~| ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} - //~| ERROR maximum number of nodes exceeded in constant v20::v17::::{constant#0} + //~^ ERROR: maximum number of nodes exceeded in constant v20::v17::::{constant#0} + //~| ERROR: maximum number of nodes exceeded in constant v20::v17::::{constant#0} + //~| ERROR: maximum number of nodes exceeded in constant v20::v17::::{constant#0} pub const fn v21() -> v18 { //~^ ERROR cannot find type `v18` in this scope v18 { _p: () } diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index 022074181cecd..c2df999dc7647 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `v20::v13` - --> $DIR/unevaluated-const-ice-119731.rs:42:15 + --> $DIR/unevaluated-const-ice-119731.rs:39:15 | LL | pub use v20::{v13, v17}; | ^^^ no `v13` in `v20` @@ -32,7 +32,7 @@ LL + pub const fn v21() -> v11 {} | error[E0425]: cannot find type `v18` in this scope - --> $DIR/unevaluated-const-ice-119731.rs:35:31 + --> $DIR/unevaluated-const-ice-119731.rs:32:31 | LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here @@ -47,7 +47,7 @@ LL + pub const fn v21() -> v11 { | error[E0422]: cannot find struct, variant or union type `v18` in this scope - --> $DIR/unevaluated-const-ice-119731.rs:37:13 + --> $DIR/unevaluated-const-ice-119731.rs:34:13 | LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here @@ -115,30 +115,6 @@ LL | impl v17 { | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: maximum number of nodes exceeded in constant v20::v17::::{constant#0} - --> $DIR/unevaluated-const-ice-119731.rs:28:37 - | -LL | impl v17 { - | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: maximum number of nodes exceeded in constant v20::v17::::{constant#0} - --> $DIR/unevaluated-const-ice-119731.rs:28:37 - | -LL | impl v17 { - | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: maximum number of nodes exceeded in constant v20::v17::::{constant#0} - --> $DIR/unevaluated-const-ice-119731.rs:28:37 - | -LL | impl v17 { - | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error[E0592]: duplicate definitions with name `v21` --> $DIR/unevaluated-const-ice-119731.rs:23:9 | @@ -148,7 +124,7 @@ LL | pub const fn v21() -> v18 {} LL | pub const fn v21() -> v18 { | ------------------------- other definition for `v21` -error: aborting due to 14 previous errors; 2 warnings emitted +error: aborting due to 11 previous errors; 2 warnings emitted Some errors have detailed explanations: E0422, E0425, E0432, E0592. For more information about an error, try `rustc --explain E0422`. diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index 82569be1a7bae..21ea451a2ea5c 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -10,7 +10,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = false) +note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:29:25 + | +LL | reuse to_reuse::opaque_ret; + | ^^^^^^^^^^ = 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[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` @@ -25,7 +29,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = false) +note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:32:24 + | +LL | reuse ToReuse::opaque_ret; + | ^^^^^^^^^^ = 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 2 previous errors diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr index 445aeb469476b..c43b4cd8defe3 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr @@ -22,20 +22,6 @@ LL | where LL | T: AsExpression, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::check` -error[E0277]: the trait bound `&str: AsExpression` is not satisfied - --> $DIR/as_expression.rs:56:5 - | -LL | SelectInt.check("bar"); - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `AsExpression` is not implemented for `&str` - | -help: the trait `AsExpression` is not implemented for `&str` - but trait `AsExpression` is implemented for it - --> $DIR/as_expression.rs:40:1 - | -LL | impl AsExpression for &'_ str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: for that trait implementation, expected `Text`, found `Integer` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs index 86f39e43484e7..ca8b95f79bbee 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs @@ -55,5 +55,4 @@ impl Foo for T where T: Expression {} fn main() { SelectInt.check("bar"); //~^ ERROR the trait bound `&str: AsExpression` is not satisfied - //[next]~| ERROR the trait bound `&str: AsExpression` is not satisfied } diff --git a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.next.stderr b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.next.stderr index 27418eb05dc7d..33f11dc2b99d0 100644 --- a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.next.stderr +++ b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.next.stderr @@ -1,12 +1,8 @@ -error[E0308]: mismatched types +error: higher-ranked subtype error --> $DIR/must-prove-where-clauses-on-norm.rs:23:61 | LL | let func: for<'a, 'b> fn((), &'b str) -> &'static str = foo::<()>; - | ^^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'b> fn((), &'b _) -> &_` - found fn pointer `for<'b> fn((), &'b _) -> &_` + | ^^^^^^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs index 064ed18248206..29166ba00c5e1 100644 --- a/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs +++ b/tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs @@ -22,7 +22,7 @@ fn foo<'a, 'b, T: Trait>(_: ::Assoc<'a, 'b>, x: &'b str) -> &'a str fn main() { let func: for<'a, 'b> fn((), &'b str) -> &'static str = foo::<()>; //[current]~^ ERROR higher-ranked lifetime error - //[next]~^^ ERROR mismatched types + //[next]~^^ ERROR higher-ranked subtype error let x: &'static str = func((), &String::from("temporary")); println!("{x}"); } diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr index f2e249f2cbf99..3398ed2120349 100644 --- a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr +++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr @@ -25,25 +25,13 @@ LL | type LineStream<'c, 'd> = impl Stream; | = note: `LineStream` must be used in combination with a concrete type within the same impl -error[E0271]: type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to ()` +error[E0271]: type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:29:43 | LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ -error[E0271]: type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` - --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:29:73 - | -LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} - | ^^ types differ - -error[E0271]: type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` - --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:29:5 - | -LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ - -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0049, E0271, E0407. For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs index 7cf155ce01ef4..dd94458d988e6 100644 --- a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs +++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs @@ -29,9 +29,7 @@ impl X for Y { fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} //~^ ERROR method `line_stream` is not a member of trait `X` //[current]~^^ ERROR `()` is not a future - //[next]~^^^ ERROR type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to ()` - //[next]~| ERROR type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` - //[next]~| ERROR type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` + //[next]~^^^ ERROR: type mismatch resolving `::LineStreamFut<'a, Repr> normalizes-to _` } pub fn main() {} diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs index ba6dfd4dfa8f6..c87c8e90d741b 100644 --- a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs @@ -13,8 +13,6 @@ struct W(T); // `usize: Foo` doesn't hold. Therefore we ICE, because we don't expect to still // encounter weak types in `assemble_alias_bound_candidates_recur`. fn hello(_: W>) {} -//~^ ERROR the trait bound `usize: Foo` is not satisfied -//~| ERROR the trait bound `usize: Foo` is not satisfied -//~| ERROR the trait bound `usize: Foo` is not satisfied - +//~^ ERROR: the trait bound `usize: Foo` is not satisfied +//~| ERROR: the trait bound `usize: Foo` is not satisfied fn main() {} 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 03c5d7a567690..dec94730df615 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 @@ -16,10 +16,10 @@ 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:15:10 + --> $DIR/alias-bounds-when-not-wf.rs:15:13 | LL | fn hello(_: W>) {} - | ^ the trait `Foo` is not implemented for `usize` + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `usize` | help: this trait has no implementations, consider adding one --> $DIR/alias-bounds-when-not-wf.rs:5:1 @@ -27,18 +27,6 @@ help: this trait has no implementations, consider adding one LL | trait Foo {} | ^^^^^^^^^ -error[E0277]: the trait bound `usize: Foo` is not satisfied - --> $DIR/alias-bounds-when-not-wf.rs:15:1 - | -LL | fn hello(_: W>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `usize` - | -help: this trait has no implementations, consider adding one - --> $DIR/alias-bounds-when-not-wf.rs:5:1 - | -LL | trait Foo {} - | ^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr b/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr index f4b60aa9b2054..e3c8c8dfa337d 100644 --- a/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr +++ b/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr @@ -1,16 +1,11 @@ error[E0277]: the trait bound `String: Trait` is not satisfied - --> $DIR/avoid-inference-constraints-from-blanket-3.rs:22:5 + --> $DIR/avoid-inference-constraints-from-blanket-3.rs:22:17 | LL | impls_trait(x); - | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ----------- ^ the trait `Trait` is not implemented for `String` + | | + | required by a bound introduced by this call | -help: the trait `Trait` is not implemented for `String` - but trait `Trait` is implemented for it - --> $DIR/avoid-inference-constraints-from-blanket-3.rs:17:1 - | -LL | impl Trait for String {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: for that trait implementation, expected `u64`, found `u32` note: required for `String` to implement `Trait` --> $DIR/avoid-inference-constraints-from-blanket-3.rs:16:15 | @@ -23,6 +18,10 @@ note: required by a bound in `impls_trait` | LL | fn impls_trait, U>(_: T) {} | ^^^^^^^^ required by this bound in `impls_trait` +help: consider borrowing here + | +LL | impls_trait(&x); + | + error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr index 5dc66f454652a..6c173c3ae8fe1 100644 --- a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr @@ -16,7 +16,7 @@ LL | fn create_complex_future() -> impl Future { | ^^^^^^^^^^^ error[E0733]: recursion in an async block requires boxing - --> $DIR/ice-issue-146191.rs:8:5 + --> $DIR/ice-issue-146191.rs:9:5 | LL | async { create_complex_future().await } | ^^^^^ ----------------------------- recursive call here diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr index 4a88359ca9679..e146d492155f0 100644 --- a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/ice-issue-146191.rs:8:5 + --> $DIR/ice-issue-146191.rs:6:31 | -LL | async { create_complex_future().await } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | fn create_complex_future() -> impl Future { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs index 84f139da4e32a..822364372bcc2 100644 --- a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs @@ -5,9 +5,9 @@ fn create_complex_future() -> impl Future { //[current]~^ ERROR the trait bound `(): ReturnsSend` is not satisfied + //[next]~^^ ERROR type annotations needed async { create_complex_future().await } //[current]~^ ERROR recursion in an async block requires - //[next]~^^ ERROR type annotations needed } trait ReturnsSend {} diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index 4b7e312644d25..59bcdd9f3cea2 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr @@ -21,10 +21,10 @@ LL | let (x,): ((_,),) = (build2(x),); | +++++++++ error[E0282]: type annotations needed - --> $DIR/recursive-in-exhaustiveness.rs:40:5 + --> $DIR/recursive-in-exhaustiveness.rs:37:23 | -LL | build3(x) - | ^^^^^^^^^ cannot infer type +LL | fn build3(x: T) -> impl Sized { + | ^^^^^^^^^^ cannot infer type error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs index 7aee8a630a5c8..32913471f02db 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs @@ -36,9 +36,9 @@ fn build2(x: T) -> impl Sized { // Not allowed today. Detected as not defining. fn build3(x: T) -> impl Sized { //[current]~^ ERROR cannot resolve opaque type + //[next]~^^ ERROR type annotations needed let (x,) = (build3((x,)),); build3(x) - //[next]~^ ERROR type annotations needed } fn main() {} diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr index 9b18a9715f21f..fac4776905d06 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/two_tait_defining_each_other2.rs:12:8 + --> $DIR/two_tait_defining_each_other2.rs:12:11 | LL | fn muh(x: A) -> B { - | ^ cannot infer type + | ^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/unsized_coercion.next.stderr b/tests/ui/impl-trait/unsized_coercion.next.stderr index bea5ddb0aefcc..f5ca850336fbc 100644 --- a/tests/ui/impl-trait/unsized_coercion.next.stderr +++ b/tests/ui/impl-trait/unsized_coercion.next.stderr @@ -1,11 +1,19 @@ error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/unsized_coercion.rs:14:17 + --> $DIR/unsized_coercion.rs:12:15 + | +LL | fn hello() -> Box { + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Trait` + +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/unsized_coercion.rs:15:17 | LL | let x = hello(); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/unsized_coercion.rs b/tests/ui/impl-trait/unsized_coercion.rs index 2cbf0d25d7ec6..3f5ec3de89f31 100644 --- a/tests/ui/impl-trait/unsized_coercion.rs +++ b/tests/ui/impl-trait/unsized_coercion.rs @@ -10,6 +10,7 @@ trait Trait {} impl Trait for u32 {} fn hello() -> Box { +//[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time if true { let x = hello(); //[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time diff --git a/tests/ui/impl-trait/unsized_coercion3.next.stderr b/tests/ui/impl-trait/unsized_coercion3.next.stderr index a480a69a38641..d254524f5d85c 100644 --- a/tests/ui/impl-trait/unsized_coercion3.next.stderr +++ b/tests/ui/impl-trait/unsized_coercion3.next.stderr @@ -1,5 +1,17 @@ error[E0277]: the trait bound `dyn Send: Trait` is not satisfied - --> $DIR/unsized_coercion3.rs:13:17 + --> $DIR/unsized_coercion3.rs:11:15 + | +LL | fn hello() -> Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Send` + | +help: the trait `Trait` is implemented for `u32` + --> $DIR/unsized_coercion3.rs:9:1 + | +LL | impl Trait for u32 {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `dyn Send: Trait` is not satisfied + --> $DIR/unsized_coercion3.rs:14:17 | LL | let x = hello(); | ^^^^^^^ the trait `Trait` is not implemented for `dyn Send` @@ -10,6 +22,6 @@ help: the trait `Trait` is implemented for `u32` LL | impl Trait for u32 {} | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/unsized_coercion3.old.stderr b/tests/ui/impl-trait/unsized_coercion3.old.stderr index 52a72b84a8dd6..3bb9f9c209510 100644 --- a/tests/ui/impl-trait/unsized_coercion3.old.stderr +++ b/tests/ui/impl-trait/unsized_coercion3.old.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time - --> $DIR/unsized_coercion3.rs:15:32 + --> $DIR/unsized_coercion3.rs:16:32 | LL | let y: Box = x; | ^ doesn't have a size known at compile-time diff --git a/tests/ui/impl-trait/unsized_coercion3.rs b/tests/ui/impl-trait/unsized_coercion3.rs index ebfbb2955de55..021d43dac6402 100644 --- a/tests/ui/impl-trait/unsized_coercion3.rs +++ b/tests/ui/impl-trait/unsized_coercion3.rs @@ -9,6 +9,7 @@ trait Trait {} impl Trait for u32 {} fn hello() -> Box { +//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied if true { let x = hello(); //[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied diff --git a/tests/ui/issues/issue-33941.rs b/tests/ui/issues/issue-33941.rs index b0736204a0811..e49efc3bfd496 100644 --- a/tests/ui/issues/issue-33941.rs +++ b/tests/ui/issues/issue-33941.rs @@ -7,6 +7,8 @@ use std::collections::HashMap; fn main() { for _ in HashMap::new().iter().cloned() {} - //~^ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` - //~| ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //[current]~^ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //[current]~| ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //[next]~^^^ ERROR: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //[next]~| ERROR: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` } 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..06aecc21be70e 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 @@ -5,9 +5,8 @@ fn main() { let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments - //[next]~^^ ERROR expected a `FnMut(& as Iterator>::Item)` closure, found + //[next]~^^ ERROR: expected a `FnMut(&{integer})` closure, found 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 a `FnMut(& as Iterator>::Item)` closure, found + //[next]~^^ ERROR: expected a `FnMut(&{integer})` 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 7912ed4d7071a..3423ce65a0c1b 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 @@ -1,38 +1,31 @@ -error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` +error[E0277]: expected a `FnMut(&{integer})` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:29 | LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&{integer})` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` - = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` + = help: the trait `for<'a> FnMut(&'a {integer})` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + = note: expected a closure with signature `for<'a> fn(&'a {integer})` found a closure with signature `fn(i32)` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -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:24 - | -LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); - | ^^^^ expected `&&i32`, found integer - -error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` +error[E0277]: expected a `FnMut(&{integer})` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:29 | LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&{integer})` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` - = note: expected a closure with signature `for<'a> fn(&'a as Iterator>::Item)` + = help: the trait `for<'a> FnMut(&'a {integer})` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + = note: expected a closure with signature `for<'a> fn(&'a {integer})` found a closure with signature `fn(&&&i32)` 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: aborting due to 2 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 E0277`. 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..fbfc425860250 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 @@ -5,9 +5,8 @@ fn main() { let _ = (-10..=10).find(|x: i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments - //[next]~^^ ERROR expected a `FnMut(& as Iterator>::Item)` closure, found + //[next]~^^ ERROR: expected a `FnMut(&{integer})` closure, found 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 a `FnMut(& as Iterator>::Item)` closure, found + //[next]~^^ ERROR: expected a `FnMut(&{integer})` closure, found } diff --git a/tests/ui/specialization/coherence/default-item-normalization-ambig-1.rs b/tests/ui/specialization/coherence/default-item-normalization-ambig-1.rs index 24142a472fde4..c0cab37130d6b 100644 --- a/tests/ui/specialization/coherence/default-item-normalization-ambig-1.rs +++ b/tests/ui/specialization/coherence/default-item-normalization-ambig-1.rs @@ -1,4 +1,4 @@ -// regression test for #73299. +// regression test for #74299. #![feature(specialization)] trait X { @@ -18,7 +18,7 @@ trait Y { impl Y for <() as X>::U {} impl Y for ::U {} -//~^ ERROR conflicting implementations of trait `Y` for type `<() as X>::U` +//~^ ERROR conflicting implementations of trait `Y` fn main() { ().f().g(); diff --git a/tests/ui/specialization/coherence/default-item-normalization-ambig-1.stderr b/tests/ui/specialization/coherence/default-item-normalization-ambig-1.stderr index f45c4e55572bf..1c1364543e772 100644 --- a/tests/ui/specialization/coherence/default-item-normalization-ambig-1.stderr +++ b/tests/ui/specialization/coherence/default-item-normalization-ambig-1.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Y` for type `<() as X>::U` +error[E0119]: conflicting implementations of trait `Y` --> $DIR/default-item-normalization-ambig-1.rs:20:1 | LL | impl Y for <() as X>::U {} | ----------------------- first implementation here LL | impl Y for ::U {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<() as X>::U` + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 1 previous error diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs index d4b74802c2df7..2bd8529df3991 100644 --- a/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Znext-solver=globally -// Regression test for https://github.com/rust-lang/rust/issues/151327 +// ICE regression test for https://github.com/rust-lang/rust/issues/151327 #![feature(min_specialization)] @@ -9,15 +9,14 @@ trait Foo { trait Baz {} -impl<'a, T> Foo for &'a T //~ ERROR not all trait items implemented, missing: `Item` -//~| ERROR the trait bound `&'a T: Foo` is not satisfied +impl<'a, T> Foo for &'a T where - Self::Item: 'a, //~ ERROR the trait bound `&'a T: Foo` is not satisfied + Self::Item: 'a, { } -impl<'a, T> Foo for &T //~ ERROR not all trait items implemented, missing: `Item` -//~| ERROR cannot normalize `<&_ as Foo>::Item: '_` +impl<'a, T> Foo for &T +//~^ ERROR: conflicting implementations of trait `Foo` for type `&_` where Self::Item: Baz, { diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr index df0e8fefaa848..cae27b4b31097 100644 --- a/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr @@ -1,69 +1,17 @@ -error[E0046]: not all trait items implemented, missing: `Item` - --> $DIR/next-solver-region-resolution.rs:12:1 - | -LL | type Item; - | --------- `Item` from trait -... -LL | / impl<'a, T> Foo for &'a T -LL | | -LL | | where -LL | | Self::Item: 'a, - | |___________________^ missing `Item` in implementation - -error[E0277]: the trait bound `&'a T: Foo` is not satisfied - --> $DIR/next-solver-region-resolution.rs:12:21 - | -LL | impl<'a, T> Foo for &'a T - | ^^^^^ the trait `Foo` is not implemented for `&'a T` - | -help: the trait `Foo` is not implemented for `&'a _` - but it is implemented for `&_` - --> $DIR/next-solver-region-resolution.rs:12:1 - | -LL | / impl<'a, T> Foo for &'a T -LL | | -LL | | where -LL | | Self::Item: 'a, - | |___________________^ - -error[E0277]: the trait bound `&'a T: Foo` is not satisfied - --> $DIR/next-solver-region-resolution.rs:15:17 - | -LL | Self::Item: 'a, - | ^^ the trait `Foo` is not implemented for `&'a T` - | -help: the trait `Foo` is not implemented for `&'a _` - but it is implemented for `&_` - --> $DIR/next-solver-region-resolution.rs:12:1 +error[E0119]: conflicting implementations of trait `Foo` for type `&_` + --> $DIR/next-solver-region-resolution.rs:18:1 | LL | / impl<'a, T> Foo for &'a T -LL | | LL | | where LL | | Self::Item: 'a, - | |___________________^ - -error[E0046]: not all trait items implemented, missing: `Item` - --> $DIR/next-solver-region-resolution.rs:19:1 - | -LL | type Item; - | --------- `Item` from trait + | |___________________- first implementation here ... LL | / impl<'a, T> Foo for &T LL | | LL | | where LL | | Self::Item: Baz, - | |____________________^ missing `Item` in implementation - -error: cannot normalize `<&_ as Foo>::Item: '_` - --> $DIR/next-solver-region-resolution.rs:19:1 - | -LL | / impl<'a, T> Foo for &T -LL | | -LL | | where -LL | | Self::Item: Baz, - | |____________________^ + | |____________________^ conflicting implementation for `&_` -error: aborting due to 5 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0046, E0277. -For more information about an error, try `rustc --explain E0046`. +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/alias-bound-unsound.rs b/tests/ui/traits/next-solver/alias-bound-unsound.rs index 1a00aef189d71..6cd0b0b1aaa30 100644 --- a/tests/ui/traits/next-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/next-solver/alias-bound-unsound.rs @@ -26,11 +26,9 @@ impl Foo for () { fn main() { let x = String::from("hello, world"); let _ = identity(<() as Foo>::copy_me(&x)); - //~^ ERROR overflow evaluating whether `<() as Foo>::Item` is well-formed - //~| ERROR overflow evaluating whether `&<() as Foo>::Item` is well-formed - //~| ERROR overflow evaluating the requirement `String == <() as Foo>::Item` - //~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _` - //~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _` - //~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _` + //~^ ERROR: overflow evaluating the requirement `<() as Foo>::Item == String` [E0275] + //~| ERROR: overflow evaluating the requirement `<() as Foo>::Item == _` [E0275] + //~| ERROR: overflow evaluating the requirement `<() as Foo>::Item == _` [E0275] + //~| ERROR: overflow evaluating the requirement `<() as Foo>::Item == _` [E0275] println!("{x}"); } diff --git a/tests/ui/traits/next-solver/alias-bound-unsound.stderr b/tests/ui/traits/next-solver/alias-bound-unsound.stderr index 234f4269c0c02..60e337f98d8a2 100644 --- a/tests/ui/traits/next-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/next-solver/alias-bound-unsound.stderr @@ -12,7 +12,7 @@ LL | trait Foo { LL | type Item: Copy | ^^^^ this trait's associated type doesn't have the requirement `String: Copy` -error[E0275]: overflow evaluating the requirement `String == <() as Foo>::Item` +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == String` --> $DIR/alias-bound-unsound.rs:28:22 | LL | let _ = identity(<() as Foo>::copy_me(&x)); @@ -25,25 +25,11 @@ LL | let _ = identity(<() as Foo>::copy_me(&x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` - --> $DIR/alias-bound-unsound.rs:28:22 - | -LL | let _ = identity(<() as Foo>::copy_me(&x)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0275]: overflow evaluating whether `&<() as Foo>::Item` is well-formed --> $DIR/alias-bound-unsound.rs:28:43 | LL | let _ = identity(<() as Foo>::copy_me(&x)); | ^^ -error[E0275]: overflow evaluating whether `<() as Foo>::Item` is well-formed - --> $DIR/alias-bound-unsound.rs:28:22 - | -LL | let _ = identity(<() as Foo>::copy_me(&x)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` --> $DIR/alias-bound-unsound.rs:28:22 | @@ -52,6 +38,6 @@ LL | let _ = identity(<() as Foo>::copy_me(&x)); | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/next-solver/alias-relate/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/next-solver/alias-relate/alias_eq_substs_eq_not_intercrate.stderr index 8c6840f72a7ff..5000195883cce 100644 --- a/tests/ui/traits/next-solver/alias-relate/alias_eq_substs_eq_not_intercrate.stderr +++ b/tests/ui/traits/next-solver/alias-relate/alias_eq_substs_eq_not_intercrate.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Overlaps>` for type `<_ as TraitB>::Assoc` +error[E0119]: conflicting implementations of trait `Overlaps>` --> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1 | LL | impl Overlaps> for ::Assoc {} | --------------------------------------------------------- first implementation here LL | impl Overlaps for ::Assoc {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as TraitB>::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation | = note: downstream crates may implement trait `TraitB` for type `std::boxed::Box<_>` diff --git a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.rs b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.rs index 26d63fdde993c..66d40437ffcf4 100644 --- a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.rs +++ b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.rs @@ -5,5 +5,6 @@ struct X; //~^ ERROR using function pointers as const generic parameters is forbidden //~| ERROR using function pointers as const generic parameters is forbidden //~| ERROR type annotations needed +//~| ERROR type annotations needed fn main() {} diff --git a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr index 425f2d59222e0..07eddd8c87c3d 100644 --- a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr +++ b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr @@ -4,6 +4,18 @@ error[E0284]: type annotations needed: cannot satisfy `the constant `{ || {} }` LL | struct X; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `{ || {} }` can be evaluated` +error[E0284]: type annotations needed + --> $DIR/const-region-infer-to-static-in-binder.rs:4:10 + | +LL | struct X; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required by a const generic parameter in `X` + --> $DIR/const-region-infer-to-static-in-binder.rs:4:10 + | +LL | struct X; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `X` + error: using function pointers as const generic parameters is forbidden --> $DIR/const-region-infer-to-static-in-binder.rs:4:20 | @@ -21,6 +33,6 @@ LL | struct X; = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs index d05def2cb757d..bd33e3c2f47ee 100644 --- a/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs +++ b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs @@ -12,6 +12,5 @@ struct S { fn main() { let x: S = todo!(); let y: &() = x.f; - //~^ ERROR mismatched types - //~| ERROR the trait bound `(): Wf` is not satisfied + //~^ ERROR the trait bound `(): Wf` is not satisfied } diff --git a/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr index 72be10367dac9..d484a0a1c4c28 100644 --- a/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr +++ b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr @@ -10,17 +10,6 @@ help: this trait has no implementations, consider adding one LL | trait Wf { | ^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/non-wf-in-coerce-pointers.rs:14:18 - | -LL | let y: &() = x.f; - | --- ^^^ types differ - | | - | expected due to this - | - = note: expected reference `&()` - found reference `&'static <() as Wf>::Assoc` - error[E0277]: the trait bound `(): Wf` is not satisfied --> $DIR/non-wf-in-coerce-pointers.rs:14:18 | @@ -33,7 +22,6 @@ help: this trait has no implementations, consider adding one LL | trait Wf { | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr index 34a45e9363069..117a6d740df2a 100644 --- a/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr @@ -7,7 +7,8 @@ LL | struct LocalTy; LL | impl Trait for ::Assoc {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation | - = note: overflow evaluating the requirement `_ == ::Assoc` + = note: overflow evaluating the requirement `::Assoc == _` + = note: overflow evaluating the requirement `::Assoc == _` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_ref_is_knowable_norm_overflow`) error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.next.stderr b/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.next.stderr index ed6e595d0afbe..3dd266f09145c 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.next.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.next.stderr @@ -10,33 +10,13 @@ note: required by a bound in `transmute` LL | fn transmute, R>(r: L) -> >::Proof { r } | ^^^^^^^^ required by this bound in `transmute` -error[E0275]: overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == _` +error[E0275]: overflow evaluating the requirement ` as Trait>::Proof == _` --> $DIR/item-bound-via-impl-where-clause.rs:31:21 | LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0275]: overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == String` - --> $DIR/item-bound-via-impl-where-clause.rs:31:21 - | -LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0275]: overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof: Sized` - --> $DIR/item-bound-via-impl-where-clause.rs:31:21 - | -LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the return type of a function must have a statically known size - -error[E0275]: overflow evaluating whether `< as Trait>::Proof as Trait>::Proof` is well-formed - --> $DIR/item-bound-via-impl-where-clause.rs:31:21 - | -LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0275]: overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == _` +error[E0275]: overflow evaluating the requirement ` as Trait>::Proof == _` --> $DIR/item-bound-via-impl-where-clause.rs:31:21 | LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); @@ -44,6 +24,6 @@ LL | let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.rs b/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.rs index 6ac0c1481c79a..3ddad6557693b 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.rs +++ b/tests/ui/traits/next-solver/cycles/coinduction/item-bound-via-impl-where-clause.rs @@ -30,10 +30,7 @@ fn transmute, R>(r: L) -> >::Proof { r } fn main() { let s: String = transmute::<_, String>(vec![65_u8, 66, 67]); //~^ ERROR overflow evaluating the requirement `Vec: Trait` - //[next]~| ERROR overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == _` - //[next]~| ERROR overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == String` - //[next]~| ERROR overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof: Sized` - //[next]~| ERROR overflow evaluating whether `< as Trait>::Proof as Trait>::Proof` is well-formed - //[next]~| ERROR overflow evaluating the requirement `< as Trait>::Proof as Trait>::Proof == _` + //[next]~| ERROR: overflow evaluating the requirement ` as Trait>::Proof == _` + //[next]~| ERROR: overflow evaluating the requirement ` as Trait>::Proof == _` println!("{}", s); // ABC } diff --git a/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs b/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs index 46dd6adf66225..d9f7cf8281410 100644 --- a/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs +++ b/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs @@ -16,6 +16,6 @@ impl Trait for Overflow { trait Overlap {} impl Overlap, U> for T {} impl Overlap for Overflow {} -//~^ ERROR conflicting implementations of trait `Overlap<::Assoc, _>` for type `Overflow` +//~^ ERROR: conflicting implementations of trait `Overlap` for type fn main() {} diff --git a/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.stderr b/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.stderr index 6605a28d54771..430b3acec3fb1 100644 --- a/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.stderr +++ b/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `Overlap<::Assoc, _>` for type `Overflow` +error[E0119]: conflicting implementations of trait `Overlap` for type `Overflow` --> $DIR/unproductive-in-coherence.rs:18:1 | LL | impl Overlap, U> for T {} diff --git a/tests/ui/traits/next-solver/diagnostics/projection-trait-ref.stderr b/tests/ui/traits/next-solver/diagnostics/projection-trait-ref.stderr index 463e50a2553e4..e2021eb314fb9 100644 --- a/tests/ui/traits/next-solver/diagnostics/projection-trait-ref.stderr +++ b/tests/ui/traits/next-solver/diagnostics/projection-trait-ref.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/projection-trait-ref.rs:8:12 + --> $DIR/projection-trait-ref.rs:8:13 | LL | let x: ::Assoc = (); - | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` + | ^ the trait `Trait` is not implemented for `T` | help: consider restricting type parameter `T` with trait `Trait` | @@ -10,10 +10,10 @@ LL | fn test_poly() { | +++++++ error[E0277]: the trait bound `i32: Trait` is not satisfied - --> $DIR/projection-trait-ref.rs:13:12 + --> $DIR/projection-trait-ref.rs:13:13 | LL | let x: ::Assoc = (); - | ^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32` + | ^^^ the trait `Trait` is not implemented for `i32` | help: this trait has no implementations, consider adding one --> $DIR/projection-trait-ref.rs:3:1 diff --git a/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.rs b/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.rs index 129e90a07f43a..ee0b04aec8b27 100644 --- a/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.rs +++ b/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.rs @@ -5,13 +5,15 @@ trait Trait<'a> { } fn foo(x: for<'a> fn(<() as Trait<'a>>::Assoc)) { - //~^ ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied +//~^ ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied +//~| ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied +//~| ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied +//~| ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied unsafe { std::mem::transmute::<_, ()>(x); } - //~^ ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait<'a>` is not satisfied + //~^ ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied + //~| ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied + //~| ERROR: the trait bound `for<'a> (): Trait<'a>` is not satisfied + } fn main() {} diff --git a/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.stderr b/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.stderr index e1ae981b2492c..3e03e3bbc9c2f 100644 --- a/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.stderr +++ b/tests/ui/traits/next-solver/dont-ice-on-bad-transmute-in-typeck.stderr @@ -11,10 +11,10 @@ LL | trait Trait<'a> { | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `for<'a> (): Trait<'a>` is not satisfied - --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:7:8 + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:7:11 | LL | fn foo(x: for<'a> fn(<() as Trait<'a>>::Assoc)) { - | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait<'a>` is not implemented for `()` | help: this trait has no implementations, consider adding one --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:3:1 @@ -23,10 +23,22 @@ LL | trait Trait<'a> { | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `for<'a> (): Trait<'a>` is not satisfied - --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:11:14 + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:12:43 | LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait<'a>` is not implemented for `()` + | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:3:1 + | +LL | trait Trait<'a> { + | ^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'a> (): Trait<'a>` is not satisfied + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:7:8 + | +LL | fn foo(x: for<'a> fn(<() as Trait<'a>>::Assoc)) { + | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` | help: this trait has no implementations, consider adding one --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:3:1 @@ -35,10 +47,10 @@ LL | trait Trait<'a> { | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `for<'a> (): Trait<'a>` is not satisfied - --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:11:36 + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:12:14 | LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait<'a>` is not implemented for `()` | help: this trait has no implementations, consider adding one --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:3:1 @@ -47,10 +59,10 @@ LL | trait Trait<'a> { | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `for<'a> (): Trait<'a>` is not satisfied - --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:11:43 + --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:12:36 | LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` + | ^ the trait `for<'a> Trait<'a>` is not implemented for `()` | help: this trait has no implementations, consider adding one --> $DIR/dont-ice-on-bad-transmute-in-typeck.rs:3:1 @@ -70,6 +82,6 @@ help: this trait has no implementations, consider adding one LL | trait Trait<'a> { | ^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/dyn-incompatibility.rs b/tests/ui/traits/next-solver/dyn-incompatibility.rs index 370bc410e12bb..5f815209f023c 100644 --- a/tests/ui/traits/next-solver/dyn-incompatibility.rs +++ b/tests/ui/traits/next-solver/dyn-incompatibility.rs @@ -11,6 +11,7 @@ fn copy(from: &U::From) -> U::From { pub fn copy_any(t: &T) -> T { copy::>(t) //~^ ERROR the trait bound `T: Copy` is not satisfied in `dyn Setup` + //~| ERROR the trait bound `T: Copy` is not satisfied in `dyn Setup` //~| ERROR the trait bound `T: Copy` is not satisfied // FIXME(-Znext-solver): These error messages are horrible and some of them diff --git a/tests/ui/traits/next-solver/dyn-incompatibility.stderr b/tests/ui/traits/next-solver/dyn-incompatibility.stderr index 4d51f1907775f..d637c75c40cb1 100644 --- a/tests/ui/traits/next-solver/dyn-incompatibility.stderr +++ b/tests/ui/traits/next-solver/dyn-incompatibility.stderr @@ -15,6 +15,18 @@ help: consider restricting type parameter `T` with trait `Copy` LL | pub fn copy_any(t: &T) -> T { | +++++++++++++++++++ +error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup` + --> $DIR/dyn-incompatibility.rs:12:31 + | +LL | copy::>(t) + | ^ within `dyn Setup`, the trait `Copy` is not implemented for `T` + | + = note: required because it appears within the type `dyn Setup` +help: consider restricting type parameter `T` with trait `Copy` + | +LL | pub fn copy_any(t: &T) -> T { + | +++++++++++++++++++ + error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup` --> $DIR/dyn-incompatibility.rs:12:5 | @@ -27,6 +39,6 @@ help: consider restricting type parameter `T` with trait `Copy` LL | pub fn copy_any(t: &T) -> T { | +++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/find-param-recursion-issue-152716.rs b/tests/ui/traits/next-solver/find-param-recursion-issue-152716.rs index 648796483815e..914773c82196a 100644 --- a/tests/ui/traits/next-solver/find-param-recursion-issue-152716.rs +++ b/tests/ui/traits/next-solver/find-param-recursion-issue-152716.rs @@ -14,7 +14,7 @@ fn foo() where T: for<'a> Proj<'a, Assoc = for<'b> fn(>::Assoc)>, (): Trait<>::Assoc> - //~^ ERROR overflow evaluating the requirement `(): Trait<>::Assoc>` [E0275] + //~^ ERROR: overflow evaluating the requirement `(): Trait<>::Assoc>` { } diff --git a/tests/ui/traits/next-solver/lazy-nested-obligations-2.next.stderr b/tests/ui/traits/next-solver/lazy-nested-obligations-2.next.stderr index 2e58377876e1d..462544b405218 100644 --- a/tests/ui/traits/next-solver/lazy-nested-obligations-2.next.stderr +++ b/tests/ui/traits/next-solver/lazy-nested-obligations-2.next.stderr @@ -1,10 +1,10 @@ -error[E0271]: type mismatch resolving `fn(&str) {f} == fn(&str)` +error[E0271]: type mismatch resolving `fn(&str) == fn(&str) {f}` --> $DIR/lazy-nested-obligations-2.rs:20:21 | LL | let _: V = V(f); | ^^^^ types differ -error[E0271]: type mismatch resolving `fn(&str) {f} == fn(&str)` +error[E0271]: type mismatch resolving `fn(&str) == fn(&str) {f}` --> $DIR/lazy-nested-obligations-2.rs:27:22 | LL | let _: E3 = E3::Var(f); diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr index cb1bbd4c61716..ecd86dba97994 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr +++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr @@ -6,20 +6,44 @@ LL | | where LL | | Self::Assoc: A, | |__________________________^ -error[E0275]: overflow evaluating the requirement `<() as A>::Assoc: A` +error[E0275]: overflow evaluating the requirement `<() as A>::Assoc == _` + --> $DIR/normalize-param-env-2.rs:22:5 + | +LL | / fn f() +LL | | where +LL | | Self::Assoc: A, + | |__________________________^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0275]: overflow evaluating the requirement `<() as A>::Assoc == _` --> $DIR/normalize-param-env-2.rs:24:22 | LL | Self::Assoc: A, | ^^^^ + +error[E0283]: type annotations needed + --> $DIR/normalize-param-env-2.rs:24:22 + | +LL | Self::Assoc: A, + | ^^^^ cannot infer type | -note: the requirement `<() as A>::Assoc: A` appears on the `impl`'s associated function `f` but not on the corresponding trait's associated function +note: multiple `impl`s or `where` clauses satisfying `_: A` found + --> $DIR/normalize-param-env-2.rs:19:1 + | +LL | impl A for () { + | ^^^^^^^^^^^^^^^^^^^ +... +LL | Self::Assoc: A, + | ^^^^ +note: the requirement `_: A` appears on the `impl`'s associated function `f` but not on the corresponding trait's associated function --> $DIR/normalize-param-env-2.rs:12:8 | LL | trait A { | - in this trait ... LL | fn f() - | ^ this trait's associated function doesn't have the requirement `<() as A>::Assoc: A` + | ^ this trait's associated function doesn't have the requirement `_: A` error[E0275]: overflow evaluating the requirement `<() as A>::Assoc: A` --> $DIR/normalize-param-env-2.rs:24:22 @@ -39,12 +63,26 @@ error[E0275]: overflow evaluating the requirement `(): A` LL | <() as A>::f(); | ^^ -error[E0275]: overflow evaluating the requirement `<() as A>::Assoc: A` +error[E0275]: overflow evaluating the requirement `<() as A>::Assoc == _` --> $DIR/normalize-param-env-2.rs:27:9 | LL | <() as A>::f(); | ^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed + --> $DIR/normalize-param-env-2.rs:27:9 + | +LL | <() as A>::f(); + | ^^^^^^^^^^^^^^^^^ cannot infer type + | +note: multiple `impl`s or `where` clauses satisfying `_: A` found + --> $DIR/normalize-param-env-2.rs:19:1 | +LL | impl A for () { + | ^^^^^^^^^^^^^^^^^^^ +... +LL | Self::Assoc: A, + | ^^^^ note: required by a bound in `A::f` --> $DIR/normalize-param-env-2.rs:14:22 | @@ -54,6 +92,7 @@ LL | where LL | Self::Assoc: A, | ^^^^ required by this bound in `A::f` -error: aborting due to 6 previous errors +error: aborting due to 9 previous errors -For more information about this error, try `rustc --explain E0275`. +Some errors have detailed explanations: E0275, E0283. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr index b123a3d1d3e6b..06bbc51e03399 100644 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr @@ -32,14 +32,6 @@ note: required by a bound in `Bar` LL | struct Bar { | ^^^ required by this bound in `Bar` -error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static)> + 'static)>` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^-------------- - | | - | call expression requires function - error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 | @@ -52,6 +44,14 @@ help: this trait has no implementations, consider adding one LL | trait Foo { | ^^^^^^^^^ +error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 + | +LL | (self.callback)(any(), any()); + | ^^^^^^^^^^^^^^^-------------- + | | + | call expression requires function + error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0618. diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr index a188629a4758b..84f9d784b042c 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:12 + --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5 | -LL | fn test(_: Foo) { - | ^^^ cannot infer type +LL | needs_send::(); + | ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `needs_send` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr index a188629a4758b..84f9d784b042c 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:12 + --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5 | -LL | fn test(_: Foo) { - | ^^^ cannot infer type +LL | needs_send::(); + | ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `needs_send` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs index 8ff99d32f064f..fddf892e1ef1d 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs @@ -13,8 +13,8 @@ fn needs_send() {} #[define_opaque(Foo)] fn test(_: Foo) { - //~^ ERROR type annotations needed needs_send::(); + //~^ ERROR type annotations needed } #[define_opaque(Foo)] diff --git a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs index d8375a62bb376..4bf1233c4d987 100644 --- a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs +++ b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.rs @@ -27,12 +27,10 @@ fn foo() -> Inv { let mut x: Inv<_> = mk(); if false { return x; - //~^ ERROR: the trait bound `u32: Trait` is not satisfied [E0277] } x.count_ones(); x - //~^ ERROR: mismatched types [E0308] } fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr index c421222309a03..3b4c14a7cd8e3 100644 --- a/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr +++ b/tests/ui/traits/next-solver/opaques/method_autoderef_constraints.stderr @@ -1,35 +1,8 @@ error[E0277]: the trait bound `u32: Trait` is not satisfied - --> $DIR/method_autoderef_constraints.rs:29:16 - | -LL | return x; - | ^ the trait `Trait` is not implemented for `u32` - | -help: the trait `Trait` is implemented for `i32` - --> $DIR/method_autoderef_constraints.rs:16:1 - | -LL | impl Trait for i32 {} - | ^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/method_autoderef_constraints.rs:34:5 - | -LL | fn foo() -> Inv { - | --------------- - | | | - | | the expected opaque type - | expected `Inv` because of return type -... -LL | x - | ^ types differ - | - = note: expected struct `Inv` - found struct `Inv` - -error[E0277]: the trait bound `u32: Trait` is not satisfied - --> $DIR/method_autoderef_constraints.rs:25:1 + --> $DIR/method_autoderef_constraints.rs:25:13 | LL | fn foo() -> Inv { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u32` + | ^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u32` | help: the trait `Trait` is implemented for `i32` --> $DIR/method_autoderef_constraints.rs:16:1 @@ -37,7 +10,6 @@ help: the trait `Trait` is implemented for `i32` LL | impl Trait for i32 {} | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs index b2a8c8cb4ae6d..c61fbef05b224 100644 --- a/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs @@ -13,7 +13,7 @@ fn needs_bar() {} fn test::Assoc2> + Foo2::Assoc1>>() { needs_bar::(); - //~^ ERROR the trait bound `::Assoc2: Bar` is not satisfied + //~^ ERROR: the trait bound `::Assoc2: Bar` is not satisfied } fn main() {} diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs b/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs index 7c789af9e4ccd..5e5bc0a39f6a5 100644 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs +++ b/tests/ui/traits/next-solver/stalled-coroutine-obligations.rs @@ -38,9 +38,7 @@ fn stalled_auto_traits() { trait Trait { fn stalled_send(&self, b: *mut ()) -> impl Future + Send { //~^ ERROR: type mismatch resolving - //~| ERROR: type mismatch resolving async move { - //~^ ERROR: type mismatch resolving b } } diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr index 6afa406bf367e..0a01803e2168e 100644 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr +++ b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr @@ -29,34 +29,13 @@ note: captured value does not implement `Valid` LL | let foo: T = async { a }; | ^ has type `False` which does not implement `Valid` -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}` - --> $DIR/stalled-coroutine-obligations.rs:39:5 +error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:41:9: 41:19}` + --> $DIR/stalled-coroutine-obligations.rs:39:43 | LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + | ^^^^^^^^^^^^^^^^^^ types differ -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}` - --> $DIR/stalled-coroutine-obligations.rs:42:9 - | -LL | / async move { -LL | | -LL | | b -LL | | } - | |_________^ types differ - -error[E0271]: type mismatch resolving `{async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19} <: impl Future + Send` - --> $DIR/stalled-coroutine-obligations.rs:39:62 - | -LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { - | ______________________________________________________________^ -LL | | -LL | | -LL | | async move { -... | -LL | | } - | |_____^ types differ - -error: aborting due to 6 previous errors +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/traits/trivial-unsized-projection-2.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr index bf8d3c40cf653..8e114f546db4f 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr @@ -24,10 +24,10 @@ 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 + --> $DIR/trivial-unsized-projection-2.rs:22:36 | LL | const FOO: ::Assert = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^ doesn't have a size known at compile-time | = help: within `Tail`, the trait `Sized` is not implemented for `[()]` note: required because it appears within the type `Tail` @@ -35,19 +35,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` - = 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..a9ce3ba56f869 100644 --- a/tests/ui/traits/trivial-unsized-projection.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection.bad_new.stderr @@ -19,25 +19,12 @@ 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 + --> $DIR/trivial-unsized-projection.rs:20:36 | LL | const FOO: <[()] as Bad>::Assert = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^ 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/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr index 2da655afa935c..9ce0e8d957dab 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr @@ -28,13 +28,7 @@ help: consider relaxing the implicit `Sized` restriction LL | type Assoc: ?Sized; | ++++++++ -error[E0282]: type annotations needed - --> $DIR/unconstrained-projection-normalization-2.rs:20:11 - | -LL | fn foo(_: ::Assoc) {} - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `::Assoc` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0207, E0277, E0282. +Some errors have detailed explanations: E0207, E0277. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs index 899d67571e710..1d45d525c04c3 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.rs +++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs @@ -18,6 +18,5 @@ impl Every for Thing { } fn foo(_: ::Assoc) {} -//[next]~^ ERROR: type annotations needed fn main() {} diff --git a/tests/ui/transmutability/type-alias-normalization.rs b/tests/ui/transmutability/type-alias-normalization.rs index 8c8734c677e8d..b42a17c698a76 100644 --- a/tests/ui/transmutability/type-alias-normalization.rs +++ b/tests/ui/transmutability/type-alias-normalization.rs @@ -1,5 +1,6 @@ -//! regression test for https://github.com/rust-lang/rust/issues/151462 +//! ICE regression test for https://github.com/rust-lang/rust/issues/151462 //@compile-flags: -Znext-solver=globally +//@check-pass #![feature(lazy_type_alias, transmutability)] #![allow(incomplete_features)] mod assert { @@ -25,7 +26,6 @@ mod assert { fn test() { type JustUnit = (); assert::is_maybe_transmutable::(); - //~^ ERROR `JustUnit` cannot be safely transmuted into `JustUnit` } fn main() {} diff --git a/tests/ui/transmutability/type-alias-normalization.stderr b/tests/ui/transmutability/type-alias-normalization.stderr deleted file mode 100644 index d224f755c6119..0000000000000 --- a/tests/ui/transmutability/type-alias-normalization.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: `JustUnit` cannot be safely transmuted into `JustUnit` - --> $DIR/type-alias-normalization.rs:27:37 - | -LL | assert::is_maybe_transmutable::(); - | ^^^^^^^^ analyzing the transmutability of `JustUnit` is not yet supported - | -note: required by a bound in `is_maybe_transmutable` - --> $DIR/type-alias-normalization.rs:10:14 - | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function -LL | where -LL | Src: TransmuteFrom< - | ______________^ -LL | | Src, -LL | | { -LL | | Assume { -... | -LL | | }, -LL | | >, - | |_________^ required by this bound in `is_maybe_transmutable` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn test() where (): TransmuteFrom<(), Assume { alignment: true, lifetimes: true, safety: true, validity: true }> { - | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.rs b/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.rs index 73f13f22bee24..514adc66771b3 100644 --- a/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.rs +++ b/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.rs @@ -20,6 +20,6 @@ fn constrain() -> Alias { impl OtherTrait for Alias {} impl OtherTrait for i32 {} -//~^ ERROR: conflicting implementations of trait `OtherTrait` for type `Alias` +//~^ ERROR: conflicting implementations of trait `OtherTrait` for type fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.stderr b/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.stderr index 6b251cfac73c8..c9b0bb1c9e8c9 100644 --- a/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.stderr +++ b/tests/ui/type-alias-impl-trait/coherence/coherence_cross_crate.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `OtherTrait` for type `Alias` +error[E0119]: conflicting implementations of trait `OtherTrait` for type `i32` --> $DIR/coherence_cross_crate.rs:22:1 | LL | impl OtherTrait for Alias {} | ------------------------- first implementation here LL | impl OtherTrait for i32 {} - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias` + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` | = note: upstream crates may add a new impl of trait `coherence_cross_crate_trait_decl::SomeTrait` for type `i32` in future versions diff --git a/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.rs b/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.rs index a7e251b1ab99d..22dbdb28d8ba5 100644 --- a/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.rs +++ b/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.rs @@ -18,7 +18,7 @@ type TAIT = impl Sized; impl Trait for (TAIT, TAIT) {} impl Trait for (u32, i32) {} -//~^ ERROR conflicting implementations of trait `Trait` for type `(TAIT, TAIT)` +//~^ ERROR: conflicting implementations of trait `Trait` for type #[define_opaque(TAIT)] fn define() -> TAIT {} diff --git a/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.stderr b/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.stderr index ef170101b4455..874a10d4919e1 100644 --- a/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.stderr +++ b/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `(TAIT, TAIT)` +error[E0119]: conflicting implementations of trait `Trait` for type `(u32, i32)` --> $DIR/coherence_different_hidden_ty.rs:20:1 | LL | impl Trait for (TAIT, TAIT) {} | --------------------------- first implementation here LL | LL | impl Trait for (u32, i32) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(TAIT, TAIT)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u32, i32)` error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr index b50d1b60c43db..b8fe2f8e35628 100644 --- a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/constrain_in_projection2.rs:28:13 + --> $DIR/constrain_in_projection2.rs:28:27 | LL | let x = >::Assoc::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | ^^^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr index 2b53614ee3f00..147b84f23b97a 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr @@ -11,10 +11,10 @@ note: this opaque type is supposed to be constrained LL | type OneTy = impl Debug; | ^^^^^^^^^^ note: this use of `OneTy` does not have unique universal generic arguments - --> $DIR/generic_nondefining_use.rs:23:5 + --> $DIR/generic_nondefining_use.rs:20:21 | -LL | 5u32 - | ^^^^ +LL | fn concrete_ty() -> OneTy { + | ^^^^^^^^^^ error: non-defining use of `OneLifetime<'_>` in the defining scope --> $DIR/generic_nondefining_use.rs:27:1 @@ -35,10 +35,10 @@ note: this opaque type is supposed to be constrained LL | type OneConst = impl Debug; | ^^^^^^^^^^ note: this use of `OneConst<123>` does not have unique universal generic arguments - --> $DIR/generic_nondefining_use.rs:38:5 + --> $DIR/generic_nondefining_use.rs:35:24 | -LL | 7u32 - | ^^^^ +LL | fn concrete_const() -> OneConst<{ 123 }> { + | ^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr index 2f44ee481adcd..89710fba6f591 100644 --- a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr +++ b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr @@ -1,29 +1,29 @@ -error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` +error[E0119]: conflicting implementations of trait `Bop` --> $DIR/impl_trait_for_same_tait.rs:18:1 | LL | impl Bop for Bar<()> {} | -------------------- first implementation here ... LL | impl Bop for Bar {} - | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation -error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` +error[E0119]: conflicting implementations of trait `Bop` --> $DIR/impl_trait_for_same_tait.rs:28:1 | LL | impl Bop for Bar<()> {} | -------------------- first implementation here ... LL | impl Bop for Barr {} - | ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + | ^^^^^^^^^^^^^^^^^ conflicting implementation -error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` +error[E0119]: conflicting implementations of trait `Bop` for type `i32` --> $DIR/impl_trait_for_same_tait.rs:32:1 | LL | impl Bop for Bar<()> {} | -------------------- first implementation here ... LL | impl Bop for i32 {} - | ^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr index 3bc6b9205ec15..be2087e11a88b 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `Yay` for type `<() as HideIt>::Assoc` +error[E0119]: conflicting implementations of trait `Yay` for type `i32` --> $DIR/implied_lifetime_wf_check.rs:27:1 | LL | impl Yay for <() as HideIt>::Assoc {} | ---------------------------------- first implementation here LL | #[cfg(error)] LL | impl Yay for i32 {} - | ^^^^^^^^^^^^^^^^ conflicting implementation for `<() as HideIt>::Assoc` + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr index 577d8667a57ad..29be8edd44f58 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.current.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `Trait` +error[E0119]: conflicting implementations of trait `Trait<(), _>` --> $DIR/issue-84660-unsoundness.rs:31:1 | LL | impl Trait for Out { 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 f7e0245bc8319..1c07b29887b1e 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 @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `Trait` +error[E0119]: conflicting implementations of trait `Trait<(), _>` --> $DIR/issue-84660-unsoundness.rs:31:1 | LL | impl Trait for Out { @@ -8,15 +8,10 @@ LL | impl Trait<(), In> for Out { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0282]: type annotations needed - --> $DIR/issue-84660-unsoundness.rs:24:37 + --> $DIR/issue-84660-unsoundness.rs:24:27 | -LL | fn convert(_i: In) -> Self::Out { - | _____________________________________^ -LL | | -LL | | -LL | | unreachable!(); -LL | | } - | |_____^ cannot infer type +LL | fn convert(_i: In) -> Self::Out { + | ^^^^^^^^^ cannot infer type 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 a385138b29502..5072faa84a892 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs @@ -29,7 +29,7 @@ impl Trait for Out { } impl Trait<(), In> for Out { - //~^ ERROR conflicting implementations of trait `Trait` + //~^ ERROR: conflicting implementations of trait type Out = In; fn convert(i: In) -> Self::Out { i diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.current.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.current.stderr index 674442784ae7f..eaf7f21f6fb32 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.current.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.current.stderr @@ -3,7 +3,7 @@ error[E0277]: the trait bound `(): Foo` is not satisfied | LL | fn foo() -> impl Foo { | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` -LL | +... LL | () | -- return type was inferred to be `()` here | diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.next.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.next.stderr index d2127976e7d22..f70e4d4cae29e 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.next.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.next.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/nested-tait-inference2.rs:20:5 + --> $DIR/nested-tait-inference2.rs:18:13 | -LL | () - | ^^ cannot infer type +LL | fn foo() -> impl Foo { + | ^^^^^^^^^^^^^^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.rs b/tests/ui/type-alias-impl-trait/nested-tait-inference2.rs index 606336178e5ec..189fde2128308 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.rs +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.rs @@ -17,8 +17,8 @@ impl Foo for () {} #[define_opaque(FooX)] fn foo() -> impl Foo { //[current]~^ ERROR: the trait bound `(): Foo` is not satisfied + //[next]~^^ ERROR: type annotations needed () - //[next]~^ ERROR: type annotations needed } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs index 684f2498d5844..6571fcb475a76 100644 --- a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs +++ b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.rs @@ -5,6 +5,6 @@ type Foo = Vec; #[define_opaque(Foo)] fn make_foo() -> Foo {} -//~^ ERROR type mismatch resolving +//~^ ERROR: mismatched types fn main() {} diff --git a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr index dd73ed1a247c7..8f78629449d8e 100644 --- a/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr +++ b/tests/ui/type-alias-impl-trait/opaque-alias-relate-issue-151331.stderr @@ -1,9 +1,14 @@ -error[E0271]: type mismatch resolving `Foo == ()` +error[E0308]: mismatched types --> $DIR/opaque-alias-relate-issue-151331.rs:7:18 | LL | fn make_foo() -> Foo {} - | ^^^ types differ + | -------- ^^^ expected `Vec<_>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected struct `Vec<_>` + found unit type `()` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/bad-index-due-to-nested.next.stderr b/tests/ui/typeck/bad-index-due-to-nested.next.stderr index a0b275b7852ba..f062aa8f14d83 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.next.stderr +++ b/tests/ui/typeck/bad-index-due-to-nested.next.stderr @@ -51,26 +51,7 @@ help: consider borrowing here LL | map[&k] | + -error[E0277]: the trait bound `K: Hash` is not satisfied - --> $DIR/bad-index-due-to-nested.rs:24:5 - | -LL | map[k] - | ^^^^^^ the trait `Hash` is not implemented for `K` - | -note: required for `HashMap` to implement `Index<&K>` - --> $DIR/bad-index-due-to-nested.rs:11:12 - | -LL | impl Index<&K> for HashMap - | ^^^^^^^^^ ^^^^^^^^^^^^^ -LL | where -LL | K: Hash, - | ---- unsatisfied trait bound introduced here -help: consider restricting type parameter `K` with trait `Hash` - | -LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap, k: K) -> &'a V { - | +++++++++++++++++ - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/bad-index-due-to-nested.rs b/tests/ui/typeck/bad-index-due-to-nested.rs index e7f385865af5f..3110e9e03863f 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.rs +++ b/tests/ui/typeck/bad-index-due-to-nested.rs @@ -26,7 +26,6 @@ fn index<'a, K, V>(map: &'a HashMap, k: K) -> &'a V { //~| ERROR the trait bound `V: Copy` is not satisfied //~| ERROR mismatched types //[current]~| ERROR mismatched types - //[next]~^^^^^ ERROR the trait bound `K: Hash` is not satisfied } fn main() {} From 03cabe7babea86cf3995e61eafa118aaf48dd218 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 14:11:46 +0800 Subject: [PATCH 6/6] bless more than merely diagnostics change --- tests/crashes/101557.rs | 42 -------------- tests/crashes/119692.rs | 48 --------------- tests/crashes/136859.rs | 27 --------- .../155761-1.rs} | 12 ++-- tests/ui/const-generics/issues/issue-89304.rs | 4 +- .../const-generics/issues/issue-89304.stderr | 21 +++++++ .../dont-ice-on-normalization-failure.rs | 22 +++++++ .../dont-ice-on-normalization-failure.stderr | 27 +++++++++ ...on-with-unsatisfied-bound-2.current.stderr | 58 ------------------- ...ction-with-unsatisfied-bound-2.next.stderr | 58 ------------------- .../self-referential-closure-sig-1.rs | 24 ++++++++ .../self-referential-closure-sig-3.rs | 19 ++++++ .../self-referential-closure-sig-4.rs | 23 ++++++++ .../ui/wf/wf-normalization-sized.next.stderr | 22 ------- tests/ui/wf/wf-normalization-sized.rs | 6 +- 15 files changed, 145 insertions(+), 268 deletions(-) delete mode 100644 tests/crashes/101557.rs delete mode 100644 tests/crashes/119692.rs delete mode 100644 tests/crashes/136859.rs rename tests/{ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs => crashes/155761-1.rs} (55%) create mode 100644 tests/ui/const-generics/issues/issue-89304.stderr create mode 100644 tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs create mode 100644 tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr delete mode 100644 tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr delete mode 100644 tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr create mode 100644 tests/ui/traits/next-solver/self-referential-closure-sig-1.rs create mode 100644 tests/ui/traits/next-solver/self-referential-closure-sig-3.rs create mode 100644 tests/ui/traits/next-solver/self-referential-closure-sig-4.rs delete mode 100644 tests/ui/wf/wf-normalization-sized.next.stderr diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs deleted file mode 100644 index a0290361ed1fe..0000000000000 --- a/tests/crashes/101557.rs +++ /dev/null @@ -1,42 +0,0 @@ -//@ known-bug: #101557 -//@ compile-flags: -Copt-level=0 -#![feature(generic_const_exprs)] -use std::marker::PhantomData; - -trait Trait { - const CONST: usize; -} - -struct A { - _marker: PhantomData, -} - -impl Trait for [i8; N] { - const CONST: usize = N; -} - -impl From for A<[i8; N]> { - fn from(_: usize) -> Self { - todo!() - } -} - -impl From> for A { - fn from(_: A<[i8; T::CONST]>) -> Self { - todo!() - } -} - -fn f() -> A -where - [(); T::CONST]:, -{ - // Usage of `0` is arbitrary - let a = A::<[i8; T::CONST]>::from(0); - A::::from(a) -} - -fn main() { - // Usage of `1` is arbitrary - f::<[i8; 1]>(); -} diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs deleted file mode 100644 index 2e230f98d81d8..0000000000000 --- a/tests/crashes/119692.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ known-bug: #119692 -//@ compile-flags: -Copt-level=0 -#![allow(incomplete_features)] -#![feature(adt_const_params)] -#![feature(generic_const_exprs)] - -use std::ops::Add; - -#[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)] -pub struct Dimension; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)] -pub struct Quantity(pub(crate) S); - -impl Add> for Quantity -where - LHS: Add, -{ - type Output = Quantity<>::Output, D>; - fn add(self, rhs: Quantity) -> Self::Output { - Quantity(self.0 + rhs.0) - } -} - -impl Add for Quantity -where - LHS: Add, -{ - type Output = Quantity<>::Output, { Dimension }>; - fn add(self, rhs: RHS) -> Self::Output { - Quantity(self.0 + rhs) - } -} - -impl Add> for f32 { - type Output = Quantity; - fn add(self, rhs: Quantity) -> Self::Output { - Quantity(self + rhs.0) - } -} - -pub fn add(x: Quantity, y: Quantity) -> Quantity { - x + y -} - -fn main() { - add(Quantity::(1.0), Quantity(2.0)); -} diff --git a/tests/crashes/136859.rs b/tests/crashes/136859.rs deleted file mode 100644 index 2c926eea5e27c..0000000000000 --- a/tests/crashes/136859.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ known-bug: #136859 -#![feature(generic_const_exprs)] - -trait If {} -impl If for () {} - -trait IsZero { - type Answer; -} - -struct True; -struct False; - -impl IsZero for () -where (): If<{N == 0}> { - type Msg = True; -} - -trait Foobar {} - -impl Foobar for () -where (): IsZero {} - -impl Foobar<{{ N }}> for () -where (): IsZero {} - -fn main() {} diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs b/tests/crashes/155761-1.rs similarity index 55% rename from tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs rename to tests/crashes/155761-1.rs index 7fa189f9aac8b..ed871ebf71910 100644 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs +++ b/tests/crashes/155761-1.rs @@ -1,12 +1,14 @@ -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@ ignore-compare-mode-next-solver (explicit revisions) +//@ known-bug: #155761 +//@compile-flags: -Znext-solver // A regression test for https://github.com/rust-lang/rust/issues/151329. // Ensures we do not trigger an ICE when normalization fails for a // projection on a trait object, even if the projection has the same // trait id as the object's bound. +// ICE again after moving to eager normalization in the next solver. +// #155761 has a simplified variant which causes ICE without eager normalization. + trait Foo { type V; } @@ -18,12 +20,8 @@ struct Bar { } impl Bar> { - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied fn event(&self) { - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied (self.callback)(any(), any()); - //~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - //~| ERROR: expected function } } diff --git a/tests/ui/const-generics/issues/issue-89304.rs b/tests/ui/const-generics/issues/issue-89304.rs index d5cbfc9300b1c..e8167deec84e3 100644 --- a/tests/ui/const-generics/issues/issue-89304.rs +++ b/tests/ui/const-generics/issues/issue-89304.rs @@ -1,17 +1,17 @@ -//@ check-pass - #![feature(generic_const_exprs)] #![allow(incomplete_features)] struct GenericStruct { val: i64 } impl From> for GenericStruct<{T + 1}> { +//~^ ERROR: conflicting implementations of trait `From>` for type `GenericStruct<_>` fn from(other: GenericStruct) -> Self { Self { val: other.val } } } impl From> for GenericStruct { +//~^ ERROR: conflicting implementations of trait `From>` for type `GenericStruct<_>` fn from(other: GenericStruct<{T + 1}>) -> Self { Self { val: other.val } } diff --git a/tests/ui/const-generics/issues/issue-89304.stderr b/tests/ui/const-generics/issues/issue-89304.stderr new file mode 100644 index 0000000000000..cac8cd32915ef --- /dev/null +++ b/tests/ui/const-generics/issues/issue-89304.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `From>` for type `GenericStruct<_>` + --> $DIR/issue-89304.rs:6:1 + | +LL | impl From> for GenericStruct<{T + 1}> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error[E0119]: conflicting implementations of trait `From>` for type `GenericStruct<_>` + --> $DIR/issue-89304.rs:13:1 + | +LL | impl From> for GenericStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs new file mode 100644 index 0000000000000..302c48d173566 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs @@ -0,0 +1,22 @@ +//@compile-flags: -Znext-solver + +// Regression test for #151308 + +#![feature(lazy_type_alias)] +trait Trait { + type Associated; +} + +trait Generic {} + +type TraitObject = dyn Generic<::Associated>; +//~^ ERROR: the trait bound `i32: Trait` is not satisfied + +struct Wrap(TraitObject); +//~^ ERROR: the trait bound `i32: Trait` is not satisfied + +fn cast(x: *mut Wrap) { + x as *mut Wrap; +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr new file mode 100644 index 0000000000000..5e857df955adf --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `i32: Trait` is not satisfied + --> $DIR/dont-ice-on-normalization-failure.rs:12:32 + | +LL | type TraitObject = dyn Generic<::Associated>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32` + | +help: this trait has no implementations, consider adding one + --> $DIR/dont-ice-on-normalization-failure.rs:6:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ + +error[E0277]: the trait bound `i32: Trait` is not satisfied + --> $DIR/dont-ice-on-normalization-failure.rs:15:13 + | +LL | struct Wrap(TraitObject); + | ^^^^^^^^^^^ the trait `Trait` is not implemented for `i32` + | +help: this trait has no implementations, consider adding one + --> $DIR/dont-ice-on-normalization-failure.rs:6:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr deleted file mode 100644 index 06bbc51e03399..0000000000000 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 - | -LL | impl Bar> { - | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14 - | -LL | fn event(&self) { - | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ - -error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^-------------- - | | - | call expression requires function - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0618. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr deleted file mode 100644 index 06bbc51e03399..0000000000000 --- a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 - | -LL | impl Bar> { - | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:22:14 - | -LL | fn event(&self) { - | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ -note: required by a bound in `Bar` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 - | -LL | struct Bar { - | ^^^ required by this bound in `Bar` - -error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` - | -help: this trait has no implementations, consider adding one - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 - | -LL | trait Foo { - | ^^^^^^^^^ - -error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` - --> $DIR/object-projection-with-unsatisfied-bound-2.rs:24:9 - | -LL | (self.callback)(any(), any()); - | ^^^^^^^^^^^^^^^-------------- - | | - | call expression requires function - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0618. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs new file mode 100644 index 0000000000000..ad401602a3267 --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the first variant of trait-system-refactor-initiative#191 + +trait Indir: FnOnce(T) -> Self::Ret { + type Ret; +} +impl Indir for F where F: FnOnce(T) -> R { + type Ret = R; +} + +trait Mirror { + type Assoc<'a>; +} + +fn needs(_: impl for<'a> Indir>) {} + +fn test() where for<'a> T: Mirror = i32> { + needs::(|x| { x.to_string(); }); +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs new file mode 100644 index 0000000000000..bbbbc5c3e50cb --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-3.rs @@ -0,0 +1,19 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the third variant of trait-system-refactor-initiative#191 + +trait Ref<'a, F> { + type Input; +} + +impl<'a, F> Ref<'a, F> for u32 { + type Input = &'a u32; +} + +fn needs_super Fn(>::Input)>(_: F) {} + +fn main() { + needs_super(|_| {}); +} diff --git a/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs new file mode 100644 index 0000000000000..fb6297869356c --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-4.rs @@ -0,0 +1,23 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for the fourth variant of trait-system-refactor-initiative#191 + +trait Trait { + type Assoc<'a>; +} + +impl Trait for () { + type Assoc<'a> = &'a (); +} + +fn foo(x: Option<*mut T>) -> for<'a> fn(<() as Trait>::Assoc<'a>) { + |_| () +} + +fn main() { + let mut x = None; + let mut y = foo(x); + x = Some(&mut y); +} diff --git a/tests/ui/wf/wf-normalization-sized.next.stderr b/tests/ui/wf/wf-normalization-sized.next.stderr deleted file mode 100644 index 804dd0a252d13..0000000000000 --- a/tests/ui/wf/wf-normalization-sized.next.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time - --> $DIR/wf-normalization-sized.rs:19:11 - | -LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[[[[[u8]]]]]` - = note: slice and array elements must have `Sized` type - -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/wf-normalization-sized.rs:21:11 - | -LL | const _: as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by an implicit `Sized` bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-normalization-sized.rs b/tests/ui/wf/wf-normalization-sized.rs index e695fd93fb0ec..fbe38975f46ff 100644 --- a/tests/ui/wf/wf-normalization-sized.rs +++ b/tests/ui/wf/wf-normalization-sized.rs @@ -1,8 +1,8 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver //@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] check-pass -//@[current] known-bug: #100041 +//@ check-pass +//@ known-bug: #100041 // Should fail. Normalization can bypass well-formedness checking. // `[[[[[[u8]]]]]]` is not a well-formed type since size of type `[u8]` cannot @@ -17,8 +17,6 @@ impl WellUnformed for T { } const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); -//[next]~^ ERROR the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time const _: as WellUnformed>::RequestNormalize = (); -//[next]~^ ERROR the size for values of type `str` cannot be known at compilation time fn main() {}