From 5b40324a53a416a2d3b6668f76fc16053241806a Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 11:57:45 +0800 Subject: [PATCH 1/9] add a new normalization routine that can handle ambiguity --- .../src/solve/normalize.rs | 212 +++++++++++++++++- 1 file changed, 211 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs index 0d5a8ab98f262..58087a3c54014 100644 --- a/compiler/rustc_trait_selection/src/solve/normalize.rs +++ b/compiler/rustc_trait_selection/src/solve/normalize.rs @@ -4,7 +4,7 @@ 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, Obligation, PredicateObligations, TraitEngine}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::{ self, FallibleTypeFolder, Flags, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, @@ -17,6 +17,45 @@ use crate::error_reporting::InferCtxtErrorExt; use crate::error_reporting::traits::OverflowCause; use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError}; +/// We have to record error as a field because `infcx.at.normalize` or more widely used +/// `ocx.normalize` only expects an normalized value + obligations. +/// Errors can be reproduced by evaluating the obligations if any. +pub struct Normalized<'tcx, T> { + pub value: T, + pub obligations: PredicateObligations<'tcx>, + pub has_ambig_hr_alias: bool, + pub has_errors: bool, +} + +/// Like `deeply_normalize`, but we handle ambiguity in this routine. +/// The behavior should be same as the old solver. +/// For error, we return an infer var with the failed AliasRelate 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. +pub fn normalize<'tcx, T>(at: At<'_, 'tcx>, value: Unnormalized<'tcx, T>) -> Normalized<'tcx, T> +where + T: TypeFoldable>, +{ + let value = value.skip_normalization(); + let mut folder = ForgivingNormalizationFolder { + at, + depth: 0, + universes: vec![], + obligations: Default::default(), + has_ambig_hr_alias: false, + has_errors: false, + }; + let value = value.fold_with(&mut folder); + Normalized { + value, + obligations: folder.obligations, + has_ambig_hr_alias: folder.has_ambig_hr_alias, + has_errors: folder.has_errors, + } +} + /// Deeply normalize all aliases in `value`. This does not handle inference and expects /// its input to be already fully resolved. pub fn deeply_normalize<'tcx, T, E>( @@ -87,6 +126,177 @@ where if errors.is_empty() { Ok((value, folder.stalled_coroutine_goals)) } else { Err(errors) } } +struct ForgivingNormalizationFolder<'me, 'tcx> { + at: At<'me, 'tcx>, + depth: usize, + universes: Vec>, + obligations: PredicateObligations<'tcx>, + has_ambig_hr_alias: bool, + has_errors: bool, +} + +impl<'tcx> ForgivingNormalizationFolder<'_, 'tcx> { + fn normalize_alias_term( + &mut self, + alias_term: ty::Term<'tcx>, + has_escaping: bool, + ) -> ty::Term<'tcx> { + 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, + ), + ); + + // FIXME: maybe use `evaluate_root_goal` and check ambiguity manually. + // That has less overhead? + let mut fulfill_cx = FulfillmentCtxt::<'_, ScrubbedTraitError<'tcx>>::new(infcx); + fulfill_cx.register_predicate_obligation(infcx, obligation); + let errors = fulfill_cx.try_evaluate_obligations(infcx); + if !errors.is_empty() { + self.has_errors = true; + self.depth -= 1; + let term = self.error_to_infer(alias_term); + return term; + } + + // Return ambiguous higher ranked alias as is if it contains escaping vars. + // We can normalize it again after the binder is instantiated. + if fulfill_cx.has_pending_obligations() && has_escaping { + self.depth -= 1; + self.has_ambig_hr_alias = true; + return alias_term; + } + + // FIXME: just drain all to avoid this allocation. + self.obligations.extend(fulfill_cx.pending_obligations()); + + // 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.super_fold_with(self).into(), + ty::TermKind::Const(ct) => ct.super_fold_with(self).into(), + }; + self.depth -= 1; + result + } + + fn error_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<'tcx> TypeFolder> for ForgivingNormalizationFolder<'_, 'tcx> { + fn cx(&self) -> TyCtxt<'tcx> { + self.at.infcx.tcx + } + + fn fold_binder>>( + &mut self, + t: ty::Binder<'tcx, T>, + ) -> ty::Binder<'tcx, T> { + self.universes.push(None); + let t = t.super_fold_with(self); + self.universes.pop(); + t + } + + #[instrument(level = "trace", skip(self), ret)] + fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { + let infcx = self.at.infcx; + // We may have resolved some ty vars when normalizing parent structures. + let ty = infcx.shallow_resolve(ty); + if !ty.has_aliases() { + return ty; + } + + let ty::Alias(..) = *ty.kind() else { return ty.super_fold_with(self) }; + + 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(), true)) + .expect_type(); + PlaceholderReplacer::replace_placeholders( + infcx, + mapped_regions, + mapped_types, + mapped_consts, + &self.universes, + result, + ) + } else { + ensure_sufficient_stack(|| self.normalize_alias_term(ty.into(), false)).expect_type() + } + } + + #[instrument(level = "trace", skip(self), ret)] + fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { + let infcx = self.at.infcx; + // We may have resolved some ty vars when normalizing parent structures. + let ct = infcx.shallow_resolve_const(ct); + if !ct.has_aliases() { + return ct; + } + + let ty::ConstKind::Unevaluated(..) = ct.kind() else { return ct.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(), true)) + .expect_const(); + PlaceholderReplacer::replace_placeholders( + infcx, + mapped_regions, + mapped_types, + mapped_consts, + &self.universes, + result, + ) + } else { + ensure_sufficient_stack(|| self.normalize_alias_term(ct.into(), false)).expect_const() + } + } +} + struct NormalizationFolder<'me, 'tcx, E> { at: At<'me, 'tcx>, fulfill_cx: FulfillmentCtxt<'tcx, E>, From 506c8dfd965fd26102a60d037081fe6f248b90d4 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Tue, 21 Apr 2026 14:35:40 +0800 Subject: [PATCH 2/9] 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 | 31 +++----- .../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 | 24 +++---- compiler/rustc_trait_selection/src/solve.rs | 4 +- .../src/traits/normalize.rs | 6 +- .../src/traits/query/normalize.rs | 34 +++++---- .../src/traits/query/type_op/normalize.rs | 11 ++- compiler/rustc_ty_utils/src/ty.rs | 10 +-- 12 files changed, 57 insertions(+), 180 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..a5095ebd81277 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -90,16 +90,9 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> { // 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) - } + let (normalized_ty, obligations) = self.normalize_ty(Unnormalized::new_wip(ty))?; + self.state.obligations.extend(obligations); + (AutoderefKind::Builtin, normalized_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 +170,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 +179,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 e34628bad66b4..5941930e3e1b9 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 0d6cd53dacab2..afb11346f87f4 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 @@ -1569,13 +1569,13 @@ 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( + // FIXME: doubtful about this, normalization error now are silent unless + // we check it. add ambiguity check? + 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(), @@ -2842,13 +2842,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); @@ -2895,17 +2893,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/solve.rs b/compiler/rustc_trait_selection/src/solve.rs index 5d200c4d340ba..038d65ea97ad2 100644 --- a/compiler/rustc_trait_selection/src/solve.rs +++ b/compiler/rustc_trait_selection/src/solve.rs @@ -10,8 +10,8 @@ pub(crate) use delegate::SolverDelegate; pub use fulfill::{FulfillmentCtxt, NextSolverError, StalledOnCoroutines}; 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, + Normalized, deeply_normalize, deeply_normalize_with_skipped_universes, + 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/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index 55f1f861921ea..53fbca020921e 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -32,10 +32,12 @@ impl<'tcx> At<'_, 'tcx> { &self, value: Unnormalized<'tcx, T>, ) -> InferOk<'tcx, T> { - let value = value.skip_normalization(); if self.infcx.next_trait_solver() { - InferOk { value, obligations: PredicateObligations::new() } + let crate::solve::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/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index bd9fee90d8903..434cbcbc611df 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -22,9 +22,7 @@ use crate::infer::at::At; use crate::infer::canonical::OriginalQueryValues; use crate::infer::{InferCtxt, InferOk}; use crate::traits::normalize::needs_normalization; -use crate::traits::{ - BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer, ScrubbedTraitError, -}; +use crate::traits::{BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer}; #[extension(pub trait QueryNormalizeExt<'tcx>)] impl<'a, 'tcx> At<'a, 'tcx> { @@ -77,25 +75,25 @@ impl<'a, 'tcx> At<'a, 'tcx> { vec![] }; - if self.infcx.next_trait_solver() { - match crate::solve::deeply_normalize_with_skipped_universes::<_, ScrubbedTraitError<'tcx>>( - self, - Unnormalized::new_wip(value), - universes, - ) { - Ok(value) => { - return Ok(Normalized { value, obligations: PredicateObligations::new() }); - } - Err(_errors) => { - return Err(NoSolution); - } - } - } - if !needs_normalization(self.infcx, &value) { return Ok(Normalized { value, obligations: PredicateObligations::new() }); } + if self.infcx.next_trait_solver() { + let crate::solve::Normalized { value, obligations, has_errors, .. } = + crate::solve::normalize(self, Unnormalized::new_wip(value)); + let result = if has_errors { + Err(NoSolution) + } else { + if value.has_non_region_infer() { + Err(NoSolution) + } else { + Ok(Normalized { value, obligations }) + } + }; + return result; + } + let mut normalizer = QueryNormalizer { infcx: self.infcx, cause: self.cause, 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 b6b9142de05e17e5bfcbc134e6811432079f6cfb Mon Sep 17 00:00:00 2001 From: Adwin White Date: Fri, 24 Apr 2026 16:40:53 +0800 Subject: [PATCH 3/9] 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 d8240a0c9d70e..ba6200a60712e 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 5941930e3e1b9..b1afccf9ca909 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 ac77354f2a794..56c2a3332c371 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -101,7 +101,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) { @@ -319,7 +319,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)); @@ -473,7 +473,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. @@ -1206,7 +1206,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); @@ -1476,7 +1476,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) => { @@ -1663,11 +1663,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()); @@ -1792,7 +1792,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(); @@ -1866,7 +1866,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 5a4cd6d24a8b6..c5fda6eecd2a5 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 496a50fb4f4bdcaf5e6a33f1a6bf6d138eb23613 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 12:05:33 +0800 Subject: [PATCH 4/9] 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 2e48831e80d8b59a7aaed4e3ebdf9d0018aaa610 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 11:58:44 +0800 Subject: [PATCH 5/9] HACK: add wf for unnormalized in the next solver --- compiler/rustc_hir_analysis/src/check/check.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 26c87f14cd737..1964ad0bfa5e5 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -923,6 +923,15 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let ty = tcx.type_of(def_id).instantiate_identity(); let ty_span = tcx.ty_span(def_id); + // FIXME: Unnormalized version can ill-formed even if the normalized one is well-formed. + // Don't break the old solver for now. See `tests/ui/wf/wf-normalization-sized.rs`. + if tcx.next_trait_solver_globally() { + wfcx.register_wf_obligation( + ty_span, + Some(WellFormedLoc::Ty(def_id)), + ty.skip_normalization().into(), + ); + } let ty = wfcx.deeply_normalize(ty_span, Some(WellFormedLoc::Ty(def_id)), ty); wfcx.register_wf_obligation(ty_span, Some(WellFormedLoc::Ty(def_id)), ty.into()); wfcx.register_bound( From 55ed9d58e7dc783f921e653ac370a15cbc10deaa Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 12:06:39 +0800 Subject: [PATCH 6/9] HACK: skip impl header normalization for coherence --- .../src/traits/coherence.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 689b96779dca8..e4020a45f7516 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -230,11 +230,20 @@ fn fresh_impl_header_normalized<'tcx>( ) -> ImplHeader<'tcx> { let header = fresh_impl_header(infcx, impl_def_id, is_of_trait); - let InferOk { value: mut header, obligations } = - infcx.at(&ObligationCause::dummy(), param_env).normalize(Unnormalized::new_wip(header)); - - header.predicates.extend(obligations.into_iter().map(|o| o.predicate)); - header + // FIXME: If we normalize the header, we'll unify headers more than we want. + // That's because we replace unevaluated consts with infer vars and then they can unify with + // anything. + // Even checking the obligations later doesn't help as the cyclic const detection is in + // relating. + // See `tests/ui/const-generics/issues/issue-89304.rs` + if infcx.next_trait_solver() { + header + } else { + let InferOk { value: mut header, obligations } = + infcx.at(&ObligationCause::dummy(), param_env).normalize(Unnormalized::new_wip(header)); + header.predicates.extend(obligations.into_iter().map(|o| o.predicate)); + header + } } /// Can both impl `a` and impl `b` be satisfied by a common type (including From 86b454bb4b6c4d8cdbe3c58b37b14c731fef54bd Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 11:40:03 +0800 Subject: [PATCH 7/9] HACK: fix object projection ICE --- .../src/solve/assembly/structural_traits.rs | 5 +- ...ect-projection-with-unsatisfied-bound-3.rs | 25 ++++++ ...projection-with-unsatisfied-bound-3.stderr | 82 +++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.rs create mode 100644 tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.stderr diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index 0bbc6f483104f..50cdfe760f158 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -993,8 +993,9 @@ where .iter() .filter(|source_projection| self.projection_may_match(**source_projection, alias_term)); let Some(replacement) = matching_projections.next() else { - // This shouldn't happen. - panic!("could not replace {alias_term:?} with term from from {:?}", self.self_ty); + // This can happen when the projection on trait object isn't well-formed. + // So the matching projection is filtered out. + return Ok(None); }; // FIXME: This *may* have issues with duplicated projections. if matching_projections.next().is_some() { diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.rs b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.rs new file mode 100644 index 0000000000000..7696ebe308953 --- /dev/null +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.rs @@ -0,0 +1,25 @@ +//@compile-flags: -Znext-solver + +// Regression test for #155761. +// Previously we assume that projection with object self_ty always has the corresponding +// existential projection predicate which can be used to normalize the projection itself. +// But when the projection on the trait object isn't well-formed. The matching projection +// can be filtered out. +trait Foo { + type V; +} + +trait Callback: Fn(&T::V) {} + +fn try_object() { + >>::call(()); +//~^ ERROR: the trait bound `dyn Callback: Foo` is not satisfied [E0277] +//~| ERROR: the trait bound `dyn Callback: Foo` is not satisfied [E0277] +//~| ERROR: use of unstable library feature `fn_traits` [E0658] +//~| ERROR: the trait bound `dyn Callback: Foo` is not satisfied [E0277] +//~| ERROR: expected a `FnMut<_>` closure, found `dyn Callback, Output = ()>` [E0277] +//~| ERROR: expected a `FnOnce(&_)` closure, found `dyn Callback, Output = ()>` [E0277] +//~| ERROR: this function takes 2 arguments but 1 argument was supplied [E0061] +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.stderr new file mode 100644 index 0000000000000..23f69361c76d4 --- /dev/null +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-3.stderr @@ -0,0 +1,82 @@ +error[E0277]: the trait bound `dyn Callback: Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:6 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `dyn Callback` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:8:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0277]: the trait bound `dyn Callback: Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:5 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `dyn Callback` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:8:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0658]: use of unstable library feature `fn_traits` + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:5 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29625 for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0277]: the trait bound `dyn Callback: Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:5 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `dyn Callback` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:8:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0277]: expected a `FnMut<_>` closure, found `dyn Callback, Output = ()>` + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:6 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut<_>` closure, found `dyn Callback, Output = ()>` + | + = help: within `dyn Callback, Output = ()>`, the trait `FnOnce(&_)` is not implemented for `dyn Callback, Output = ()>` + = note: required because it appears within the type `dyn Callback, Output = ()>` +note: required by a bound in `call` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + +error[E0277]: expected a `FnOnce(&_)` closure, found `dyn Callback, Output = ()>` + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:5 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&_)` closure, found `dyn Callback, Output = ()>` + | + = help: the trait `FnOnce(&_)` is not implemented for `dyn Callback, Output = ()>` + +error[E0061]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/object-projection-with-unsatisfied-bound-3.rs:15:5 + | +LL | >>::call(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- argument #1 of type `&dyn Callback, Output = ()>` is missing + | +note: method defined here + --> $SRC_DIR/core/src/ops/function.rs:LL:COL +help: provide the argument + | +LL | >>::call(/* value */, ()); + | ++++++++++++ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0061, E0277, E0658. +For more information about an error, try `rustc --explain E0061`. From e0f4ad38db1eaedd0dd3663eec6576f5dd227ebf Mon Sep 17 00:00:00 2001 From: Adwin White Date: Tue, 21 Apr 2026 15:34:28 +0800 Subject: [PATCH 8/9] bless diagnostics changes --- ...rent-assoc-ty-mismatch-issue-153539.stderr | 5 +- ...opaque-inherent-fn-ptr-issue-155204.stderr | 9 +-- .../next-solver-opaque-inherent-no-ice.stderr | 9 +-- ...ram-env-shadowing-incompatible-args.stderr | 2 +- tests/ui/coherence/coherence-with-closure.rs | 2 +- .../ui/coherence/coherence-with-coroutine.rs | 2 +- .../unevaluated-const-ice-119731.rs | 12 ++-- 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 | 10 +-- .../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 +- .../next-solver-region-resolution.rs | 11 ++- .../next-solver-region-resolution.stderr | 67 +++---------------- .../unsatisfied-const-trait-bound.stderr | 12 +++- .../traits/next-solver/alias-bound-unsound.rs | 14 ++-- .../next-solver/alias-bound-unsound.stderr | 56 ++++++++++------ ...iguity-due-to-uniquification-4.next.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 +---- ...em-bound-via-impl-where-clause.next.stderr | 24 +------ .../item-bound-via-impl-where-clause.rs | 3 - .../cycles/normalizes-to-is-not-productive.rs | 1 + .../normalizes-to-is-not-productive.stderr | 33 ++++++++- .../cycles/unproductive-in-coherence.rs | 2 +- .../diagnostics/projection-trait-ref.stderr | 8 +-- .../dont-ice-on-bad-transmute-in-typeck.rs | 8 +-- ...dont-ice-on-bad-transmute-in-typeck.stderr | 54 +-------------- .../traits/next-solver/dyn-incompatibility.rs | 1 + .../next-solver/dyn-incompatibility.stderr | 14 +++- .../find-param-recursion-issue-152716.rs | 2 +- .../find-param-recursion-issue-152716.stderr | 12 ++-- .../lazy-nested-obligations-2.next.stderr | 4 +- .../normalize/normalize-param-env-2.stderr | 61 +++++++++++++++-- .../normalize-param-env-4.next.stderr | 20 +++++- ...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 +- .../recursive-self-normalization-2.stderr | 6 +- .../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_different_hidden_ty.rs | 2 +- .../constrain_in_projection2.next.stderr | 4 +- .../generic_nondefining_use.next.stderr | 12 ++-- .../issue-84660-unsoundness.next.stderr | 11 +-- .../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 - 86 files changed, 401 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/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..48500a543697d 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 `Wrapper` fn main() {} diff --git a/tests/ui/coherence/coherence-with-coroutine.rs b/tests/ui/coherence/coherence-with-coroutine.rs index 0e65a6c1da031..b174887a6c8fb 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 `Wrapper` fn main() {} 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..99130689d7ce2 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,12 @@ 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} + //~| 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/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 ab51e2bdae77f..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,14 +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 - | | - | expected due to this - | - = note: expected fn pointer `for<'b> fn((), &'b _) -> &'static _` - found fn item `for<'b> fn(<() as Trait>::Assoc<'_, 'b>, &'b _) -> &_ {foo::<'_, ()>}` + | ^^^^^^^^^ 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/min_specialization/next-solver-region-resolution.rs b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs index d4b74802c2df7..0f721367461e2 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: cycle detected when computing normalized predicates of 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..3609230373b86 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,22 @@ -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` +error[E0391]: cycle detected when computing normalized predicates of `` + --> $DIR/next-solver-region-resolution.rs:18:1 | -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 | / impl<'a, T> Foo for &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` +LL | | Self::Item: Baz, + | |____________________^ | -help: the trait `Foo` is not implemented for `&'a _` - but it is implemented for `&_` + = note: ...which immediately requires computing normalized predicates of `` again +note: cycle used when computing whether impls specialize one another --> $DIR/next-solver-region-resolution.rs:12:1 | LL | / impl<'a, T> Foo for &'a T -LL | | LL | | where LL | | Self::Item: 'a, | |___________________^ + = 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[E0046]: not all trait items implemented, missing: `Item` - --> $DIR/next-solver-region-resolution.rs:19:1 - | -LL | type Item; - | --------- `Item` from trait -... -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, - | |____________________^ - -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 E0391`. diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 1a2bc6c2c5f59..9df224c253cfa 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -40,10 +40,15 @@ LL | fn accept0(_: Container<{ T::make() }>) {} note: ...which requires type-checking `accept0::{constant#0}`... --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | +LL | fn accept0(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ +note: ...which requires computing normalized predicates of `accept0::{constant#0}`... + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 + | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ = note: ...which again requires evaluating type-level constant, completing the cycle -note: cycle used when checking that `accept0` is well-formed +note: cycle used when computing normalized predicates of `accept0` --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} @@ -76,6 +81,11 @@ note: ...which requires type-checking `accept1::{constant#0}`... | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ +note: ...which requires computing normalized predicates of `accept1::{constant#0}`... + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 + | +LL | const fn accept1(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires evaluating type-level constant... --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | diff --git a/tests/ui/traits/next-solver/alias-bound-unsound.rs b/tests/ui/traits/next-solver/alias-bound-unsound.rs index 1a00aef189d71..d3603accf2292 100644 --- a/tests/ui/traits/next-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/next-solver/alias-bound-unsound.rs @@ -21,16 +21,18 @@ trait Foo { impl Foo for () { type Item = String where String: Copy; //~^ ERROR overflow evaluating the requirement `String: Copy` + //~| 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] + //~| ERROR: overflow evaluating the requirement `<() as Foo>::Item == _` [E0275] } 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..2fc6c23726b7a 100644 --- a/tests/ui/traits/next-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/next-solver/alias-bound-unsound.stderr @@ -1,3 +1,33 @@ +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` + --> $DIR/alias-bound-unsound.rs:22:5 + | +LL | type Item = String where String: Copy; + | ^^^^^^^^^ + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` + --> $DIR/alias-bound-unsound.rs:22:5 + | +LL | type Item = String where String: Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` + --> $DIR/alias-bound-unsound.rs:22:5 + | +LL | type Item = String where String: Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` + --> $DIR/alias-bound-unsound.rs:22:5 + | +LL | type Item = String where String: Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0275]: overflow evaluating the requirement `String: Copy` --> $DIR/alias-bound-unsound.rs:22:38 | @@ -12,46 +42,32 @@ 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` - --> $DIR/alias-bound-unsound.rs:28:22 +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == String` + --> $DIR/alias-bound-unsound.rs:32: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 + --> $DIR/alias-bound-unsound.rs:32: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 - | -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 + --> $DIR/alias-bound-unsound.rs:32: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 + --> $DIR/alias-bound-unsound.rs:32:22 | 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 9 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.next.stderr b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.next.stderr index c7d774644c2ba..e819145e4193b 100644 --- a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.next.stderr +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.next.stderr @@ -1,8 +1,8 @@ error[E0284]: type annotations needed: cannot normalize `>::Type` - --> $DIR/ambiguity-due-to-uniquification-4.rs:17:44 + --> $DIR/ambiguity-due-to-uniquification-4.rs:17:47 | LL | pub fn f<'a, 'b, T: Trait<'a> + Trait<'b>>(v: >::Type) {} - | ^ cannot normalize `>::Type` + | ^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `>::Type` error: aborting due to 1 previous error 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/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..bc16f08a599d6 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,40 +10,18 @@ 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 == _` - --> $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 == _` --> $DIR/item-bound-via-impl-where-clause.rs:31:21 | 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..acf6a7dec8b79 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 @@ -32,8 +32,5 @@ fn main() { //~^ 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 == _` println!("{}", s); // ABC } diff --git a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs index ffbbecaf89570..8a8b22b0df9f2 100644 --- a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs +++ b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs @@ -38,6 +38,7 @@ fn impls_bound() { // - normalize `>::Assoc` // - via blanket impl, requires where-clause `Foo: Bound` -> cycle fn generic() +//~^ ERROR: the trait bound `Foo: Bound` is not satisfied where >::Assoc: Bound, //~^ ERROR the trait bound `Foo: Bound` is not satisfied diff --git a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr index f679b94a92377..e18265190278a 100644 --- a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr +++ b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr @@ -1,5 +1,32 @@ error[E0277]: the trait bound `Foo: Bound` is not satisfied - --> $DIR/normalizes-to-is-not-productive.rs:42:31 + --> $DIR/normalizes-to-is-not-productive.rs:40:1 + | +LL | / fn generic() +LL | | +LL | | where +LL | | >::Assoc: Bound, + | |____________________________________^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Foo` + --> $DIR/normalizes-to-is-not-productive.rs:18:1 + | +LL | struct Foo; + | ^^^^^^^^^^ +help: the trait `Bound` is implemented for `u32` + --> $DIR/normalizes-to-is-not-productive.rs:11:1 + | +LL | impl Bound for u32 { + | ^^^^^^^^^^^^^^^^^^ +note: required for `Foo` to implement `Trait` + --> $DIR/normalizes-to-is-not-productive.rs:23:19 + | +LL | impl Trait for T { + | ----- ^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0277]: the trait bound `Foo: Bound` is not satisfied + --> $DIR/normalizes-to-is-not-productive.rs:43:31 | LL | >::Assoc: Bound, | ^^^^^ unsatisfied trait bound @@ -30,7 +57,7 @@ LL | | } | |_^ required by this bound in `Bound` error[E0277]: the trait bound `Foo: Bound` is not satisfied - --> $DIR/normalizes-to-is-not-productive.rs:47:19 + --> $DIR/normalizes-to-is-not-productive.rs:48:19 | LL | impls_bound::(); | ^^^ unsatisfied trait bound @@ -51,6 +78,6 @@ note: required by a bound in `impls_bound` LL | fn impls_bound() { | ^^^^^ required by this bound in `impls_bound` -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/cycles/unproductive-in-coherence.rs b/tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs index 46dd6adf66225..38fdfed88cde6 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<::Assoc, _>` for type `Overflow` fn main() {} 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..7d61100862535 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,9 @@ 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 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 } 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..bdae80455935f 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 @@ -22,54 +22,6 @@ help: this trait has no implementations, consider adding one 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 - | -LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:11:36 - | -LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^ 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:11:43 - | -LL | unsafe { std::mem::transmute::<_, ()>(x); } - | ^ 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:1 - | -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 - | -LL | trait Trait<'a> { - | ^^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors +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/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..6ee01324c7115 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 @@ -11,10 +11,10 @@ trait Proj<'a> { type Assoc; } fn foo() + //~^ ERROR: overflow normalizing the associated type `>::Assoc` where T: for<'a> Proj<'a, Assoc = for<'b> fn(>::Assoc)>, (): Trait<>::Assoc> - //~^ ERROR overflow evaluating the requirement `(): Trait<>::Assoc>` [E0275] { } diff --git a/tests/ui/traits/next-solver/find-param-recursion-issue-152716.stderr b/tests/ui/traits/next-solver/find-param-recursion-issue-152716.stderr index e2ee83cfadbef..3e0a9ee7ff0c2 100644 --- a/tests/ui/traits/next-solver/find-param-recursion-issue-152716.stderr +++ b/tests/ui/traits/next-solver/find-param-recursion-issue-152716.stderr @@ -1,8 +1,12 @@ -error[E0275]: overflow evaluating the requirement `(): Trait<>::Assoc>` - --> $DIR/find-param-recursion-issue-152716.rs:16:9 +error[E0275]: overflow normalizing the associated type `>::Assoc` + --> $DIR/find-param-recursion-issue-152716.rs:13:1 | -LL | (): Trait<>::Assoc> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn foo() +LL | | +LL | | where +LL | | T: for<'a> Proj<'a, Assoc = for<'b> fn(>::Assoc)>, +LL | | (): Trait<>::Assoc> + | |__________________________________________^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`find_param_recursion_issue_152716`) 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..e3c1b4e0dcb6a 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,54 @@ 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: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: multiple `impl`s or `where` clauses satisfying `_: A` found + --> $DIR/normalize-param-env-2.rs:19:1 | -note: the requirement `<() as A>::Assoc: A` appears on the `impl`'s associated function `f` but not on the corresponding trait's associated function +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 == _` + --> $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: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: A` --> $DIR/normalize-param-env-2.rs:24:22 @@ -39,12 +73,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 +102,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 10 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/normalize/normalize-param-env-4.next.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr index 47d38365e970e..01c82c49975d4 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr +++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-4.next.stderr @@ -1,3 +1,21 @@ +error[E0275]: overflow evaluating the requirement `::Assoc == _` + --> $DIR/normalize-param-env-4.rs:17:1 + | +LL | / fn foo() +LL | | where +LL | | ::Assoc: Trait, + | |_______________________________^ + +error[E0275]: overflow evaluating the requirement `::Assoc == _` + --> $DIR/normalize-param-env-4.rs:17:1 + | +LL | / fn foo() +LL | | where +LL | | ::Assoc: Trait, + | |_______________________________^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0275]: overflow evaluating the requirement `::Assoc: Trait` --> $DIR/normalize-param-env-4.rs:19:26 | @@ -22,6 +40,6 @@ note: required by a bound in `impls_trait` LL | fn impls_trait() {} | ^^^^^ required by this bound in `impls_trait` -error: aborting due to 3 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/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..94a9484ecdcf1 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 `::Assoc1: Bar` is not satisfied } fn main() {} diff --git a/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr index c4be47e3520da..6f5111a6193ca 100644 --- a/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `::Assoc2: Bar` is not satisfied +error[E0277]: the trait bound `::Assoc1: Bar` is not satisfied --> $DIR/recursive-self-normalization-2.rs:15:17 | LL | needs_bar::(); - | ^^^^^^^^^ the trait `Bar` is not implemented for `::Assoc2` + | ^^^^^^^^^ the trait `Bar` is not implemented for `::Assoc1` | note: required by a bound in `needs_bar` --> $DIR/recursive-self-normalization-2.rs:12:17 @@ -11,7 +11,7 @@ LL | fn needs_bar() {} | ^^^ required by this bound in `needs_bar` help: consider further restricting the associated type | -LL | fn test::Assoc2> + Foo2::Assoc1>>() where ::Assoc2: Bar { +LL | fn test::Assoc2> + Foo2::Assoc1>>() where ::Assoc1: Bar { | ++++++++++++++++++++++++++++++ error: aborting due to 1 previous error 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_different_hidden_ty.rs b/tests/ui/type-alias-impl-trait/coherence/coherence_different_hidden_ty.rs index a7e251b1ab99d..fce71d38c54bc 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 `(TAIT, TAIT)` #[define_opaque(TAIT)] fn define() -> TAIT {} 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/issue-84660-unsoundness.next.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.stderr index f7e0245bc8319..3399c85a3034e 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 @@ -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..5017664aaffe2 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 `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 e4b9746d264ea9e48dc814e92274cf43998d92e0 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Sat, 25 Apr 2026 14:11:46 +0800 Subject: [PATCH 9/9] add tests for fixed issues --- .../dont-ice-on-normalization-failure.rs | 22 +++++++++++++++ .../dont-ice-on-normalization-failure.stderr | 27 +++++++++++++++++++ .../self-referential-closure-sig-1.rs | 23 ++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/ui/traits/next-solver/dont-ice-on-normalization-failure.rs create mode 100644 tests/ui/traits/next-solver/dont-ice-on-normalization-failure.stderr create mode 100644 tests/ui/traits/next-solver/self-referential-closure-sig-1.rs diff --git a/tests/ui/traits/next-solver/dont-ice-on-normalization-failure.rs b/tests/ui/traits/next-solver/dont-ice-on-normalization-failure.rs new file mode 100644 index 0000000000000..302c48d173566 --- /dev/null +++ b/tests/ui/traits/next-solver/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/dont-ice-on-normalization-failure.stderr b/tests/ui/traits/next-solver/dont-ice-on-normalization-failure.stderr new file mode 100644 index 0000000000000..5e857df955adf --- /dev/null +++ b/tests/ui/traits/next-solver/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/self-referential-closure-sig-1.rs b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs new file mode 100644 index 0000000000000..13d7739cd7742 --- /dev/null +++ b/tests/ui/traits/next-solver/self-referential-closure-sig-1.rs @@ -0,0 +1,23 @@ +//@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() {}