diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index e61c1ee98cd..e58723c2ec9 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -2059,7 +2059,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { // We currently do not store the `DefId` in the `ConstraintCategory` // for performances reasons. The error reporting code used by NLL only // uses the span, so this doesn't cause any problems at the moment. - Some(ObligationCauseCode::SpannedItem(CRATE_DEF_ID.to_def_id(), predicate_span)) + Some(ObligationCauseCode::SpannedWhereClause( + CRATE_DEF_ID.to_def_id(), + predicate_span, + )) } else { None } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index adbeacecc0c..d43dc467c0f 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -738,7 +738,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { let cause = ObligationCause::new( terminator.source_info.span, self.body.source.def_id().expect_local(), - ObligationCauseCode::MiscItem(callee), + ObligationCauseCode::WhereClause(callee), ); let normalized_predicates = ocx.normalize(&cause, param_env, predicates); ocx.register_obligations(traits::predicates_for_generics( diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 00f223f2ca3..b2b82670d8b 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -819,7 +819,7 @@ impl<'tcx> TypeFolder> for ImplTraitInTraitCollector<'_, 'tcx> { ObligationCause::new( self.span, self.body_id, - ObligationCauseCode::SpannedItem(proj.def_id, pred_span), + ObligationCauseCode::SpannedWhereClause(proj.def_id, pred_span), ), self.param_env, pred, @@ -2012,9 +2012,9 @@ pub(super) fn check_type_bounds<'tcx>( ); let mk_cause = |span: Span| { let code = if span.is_dummy() { - ObligationCauseCode::MiscItem(trait_ty.def_id) + ObligationCauseCode::WhereClause(trait_ty.def_id) } else { - ObligationCauseCode::SpannedItem(trait_ty.def_id, span) + ObligationCauseCode::SpannedWhereClause(trait_ty.def_id, span) }; ObligationCause::new(impl_ty_span, impl_ty_def_id, code) }; @@ -2251,7 +2251,8 @@ fn try_report_async_mismatch<'tcx>( }; for error in errors { - if let ObligationCauseCode::SpannedItem(def_id, _) = *error.root_obligation.cause.code() + if let ObligationCauseCode::SpannedWhereClause(def_id, _) = + *error.root_obligation.cause.code() && def_id == async_future_def_id && let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred() && let Some(proj) = proj.no_bound_vars() diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 49d4b8ecfe7..0578317f914 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1550,7 +1550,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id let cause = traits::ObligationCause::new( sp, wfcx.body_def_id, - ObligationCauseCode::MiscItem(def_id.to_def_id()), + ObligationCauseCode::WhereClause(def_id.to_def_id()), ); traits::Obligation::new(tcx, cause, wfcx.param_env, pred) }); diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 77dbb23fcb6..de697b04ebf 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -212,7 +212,7 @@ fn get_impl_args( traits::ObligationCause::new( impl1_span, impl1_def_id, - traits::ObligationCauseCode::SpannedItem(impl2_node.def_id(), span), + traits::ObligationCauseCode::SpannedWhereClause(impl2_node.def_id(), span), ) }, ); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 8e9b12cb606..c214634832b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1413,9 +1413,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { self.add_required_obligations_with_code(span, def_id, args, |idx, span| { if span.is_dummy() { - ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx) + ObligationCauseCode::WhereClauseInExpr(def_id, hir_id, idx) } else { - ObligationCauseCode::SpannedItemInExpr(def_id, span, hir_id, idx) + ObligationCauseCode::SpannedWhereClauseInExpr(def_id, span, hir_id, idx) } }) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index d1336d58eed..26996397659 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -14,8 +14,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, error: &mut traits::FulfillmentError<'tcx>, ) -> bool { - let (ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx) - | ObligationCauseCode::SpannedItemInExpr(def_id, _, hir_id, idx)) = + let (ObligationCauseCode::WhereClauseInExpr(def_id, hir_id, idx) + | ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, hir_id, idx)) = *error.obligation.cause.code().peel_derives() else { return false; @@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, ) -> Result<&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>> { match obligation_cause_code { - traits::ObligationCauseCode::SpannedItemInExpr(_, _, _, _) => { + traits::ObligationCauseCode::SpannedWhereClauseInExpr(_, _, _, _) => { // This is the "root"; we assume that the `expr` is already pointing here. // Therefore, we return `Ok` so that this `expr` can be refined further. Ok(expr) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index f82aeb63734..4bf82355b62 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -2013,7 +2013,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (span, code) in errors_causecode { self.dcx().try_steal_modify_and_emit_err(span, StashKey::MaybeForgetReturn, |err| { if let Some(fn_sig) = self.body_fn_sig() - && let ObligationCauseCode::SpannedItemInExpr(_, _, binding_hir_id, ..) = code + && let ObligationCauseCode::SpannedWhereClauseInExpr(_, _, binding_hir_id, ..) = + code && !fn_sig.output().is_unit() { let mut block_num = 0; @@ -2102,7 +2103,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // This is because due to normalization, we often register duplicate // obligations with misc obligations that are basically impossible to - // line back up with a useful SpannedItemInExpr. + // line back up with a useful SpannedWhereClauseInExpr. for error in not_adjusted { for (span, predicate, cause) in &remap_cause { if *predicate == error.obligation.predicate diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 7cb60c792ba..56c296fc1c0 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -565,9 +565,14 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { for obligation in traits::predicates_for_generics( |idx, span| { let code = if span.is_dummy() { - ObligationCauseCode::MiscItemInExpr(def_id, self.call_expr.hir_id, idx) + ObligationCauseCode::WhereClauseInExpr(def_id, self.call_expr.hir_id, idx) } else { - ObligationCauseCode::SpannedItemInExpr(def_id, span, self.call_expr.hir_id, idx) + ObligationCauseCode::SpannedWhereClauseInExpr( + def_id, + span, + self.call_expr.hir_id, + idx, + ) }; traits::ObligationCause::new(self.span, self.body_id, code) }, diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 8d5696d3e5c..434bd957498 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1402,13 +1402,13 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { ocx.register_obligations(traits::predicates_for_generics( |idx, span| { let code = if span.is_dummy() { - ObligationCauseCode::MiscItemInExpr( + ObligationCauseCode::WhereClauseInExpr( impl_def_id, self.scope_expr_id, idx, ) } else { - ObligationCauseCode::SpannedItemInExpr( + ObligationCauseCode::SpannedWhereClauseInExpr( impl_def_id, span, self.scope_expr_id, diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index aa814d2b457..42429812d9f 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -830,8 +830,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (data.impl_or_alias_def_id, data.span) } Some( - ObligationCauseCode::SpannedItemInExpr(def_id, span, _, _) - | ObligationCauseCode::SpannedItem(def_id, span), + ObligationCauseCode::SpannedWhereClauseInExpr(def_id, span, _, _) + | ObligationCauseCode::SpannedWhereClause(def_id, span), ) => (*def_id, *span), _ => continue, }; diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 8354dfe3bf3..89cdc3e45a5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -883,8 +883,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { err.help("...or use `match` instead of `let...else`"); } _ => { - if let ObligationCauseCode::SpannedItem(_, span) - | ObligationCauseCode::SpannedItemInExpr(_, span, ..) = + if let ObligationCauseCode::SpannedWhereClause(_, span) + | ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) = cause.code().peel_derives() && let TypeError::RegionsPlaceholderMismatch = terr { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs index 30116b43297..b6c38739e9a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs @@ -38,8 +38,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else { return None; }; - let (ObligationCauseCode::SpannedItem(_, binding_span) - | ObligationCauseCode::SpannedItemInExpr(_, binding_span, ..)) = *parent.code() + let (ObligationCauseCode::SpannedWhereClause(_, binding_span) + | ObligationCauseCode::SpannedWhereClauseInExpr(_, binding_span, ..)) = *parent.code() else { return None; }; diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index c9dc38cb98f..e3476d8c394 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -240,8 +240,8 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { let span = cause.span(); let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = - if let ObligationCauseCode::MiscItem(def_id) - | ObligationCauseCode::MiscItemInExpr(def_id, ..) = *cause.code() + if let ObligationCauseCode::WhereClause(def_id) + | ObligationCauseCode::WhereClauseInExpr(def_id, ..) = *cause.code() { ( true, diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index c6176c5d3d8..e5950a7c935 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -214,8 +214,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { _ => cause.code(), } && let ( - &ObligationCauseCode::MiscItem(item_def_id) - | &ObligationCauseCode::MiscItemInExpr(item_def_id, ..), + &ObligationCauseCode::WhereClause(item_def_id) + | &ObligationCauseCode::WhereClauseInExpr(item_def_id, ..), None, ) = (code, override_error_code) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index b1d978867cb..ecbe65fe926 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -357,13 +357,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { infer::Subtype(box ref trace) if matches!( &trace.cause.code().peel_derives(), - ObligationCauseCode::SpannedItem(..) - | ObligationCauseCode::SpannedItemInExpr(..) + ObligationCauseCode::SpannedWhereClause(..) + | ObligationCauseCode::SpannedWhereClauseInExpr(..) ) => { // Hack to get around the borrow checker because trace.cause has an `Rc`. - if let ObligationCauseCode::SpannedItem(_, span) - | ObligationCauseCode::SpannedItemInExpr(_, span, ..) = + if let ObligationCauseCode::SpannedWhereClause(_, span) + | ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) = &trace.cause.code().peel_derives() { let span = *span; @@ -371,7 +371,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { .with_span_note(span, "the lifetime requirement is introduced here") } else { unreachable!( - "control flow ensures we have a `BindingObligation` or `SpannedItemInExpr` here..." + "control flow ensures we have a `BindingObligation` or `SpannedWhereClauseInExpr` here..." ) } } diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 58eeec9956d..94f8a2664f9 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -103,8 +103,8 @@ impl<'tcx> InferCtxt<'tcx> { cause.span, sup_type, match cause.code().peel_derives() { - ObligationCauseCode::SpannedItem(_, span) - | ObligationCauseCode::SpannedItemInExpr(_, span, ..) => Some(*span), + ObligationCauseCode::SpannedWhereClause(_, span) + | ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) => Some(*span), _ => None, }, ) diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 5e5f28a54e8..6c33a29ea81 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -249,20 +249,20 @@ pub enum ObligationCauseCode<'tcx> { /// Must satisfy all of the where-clause predicates of the /// given item. - MiscItem(DefId), + WhereClause(DefId), - /// Like `MiscItem`, but carries the span of the + /// Like `WhereClause`, but carries the span of the /// predicate when it can be identified. - SpannedItem(DefId, Span), + SpannedWhereClause(DefId, Span), - /// Like `MiscItem`, but carries the `HirId` of the + /// Like `WhereClause`, but carries the `HirId` of the /// expression that caused the obligation, and the `usize` /// indicates exactly which predicate it is in the list of /// instantiated predicates. - MiscItemInExpr(DefId, HirId, usize), + WhereClauseInExpr(DefId, HirId, usize), - /// Combines `SpannedItem` and `MiscItemInExpr`. - SpannedItemInExpr(DefId, Span, HirId, usize), + /// Combines `SpannedWhereClause` and `WhereClauseInExpr`. + SpannedWhereClauseInExpr(DefId, Span, HirId, usize), /// A type like `&'a T` is WF only if `T: 'a`. ReferenceOutlivesReferent(Ty<'tcx>), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 9839f4768e2..3defc03e7f0 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1203,7 +1203,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let code = match obligation.cause.code() { ObligationCauseCode::FunctionArg { parent_code, .. } => parent_code, - c @ ObligationCauseCode::MiscItem(_) | c @ ObligationCauseCode::MiscItemInExpr(..) => c, + c @ ObligationCauseCode::WhereClause(_) + | c @ ObligationCauseCode::WhereClauseInExpr(..) => c, c if matches!( span.ctxt().outer_expn_data().kind, ExpnKind::Desugaring(DesugaringKind::ForLoop) @@ -1259,8 +1260,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let mut_ref_self_ty_satisfies_pred = mk_result(trait_pred_and_mut_ref); let (ref_inner_ty_satisfies_pred, ref_inner_ty_mut) = - if let ObligationCauseCode::MiscItem(_) | ObligationCauseCode::MiscItemInExpr(..) = - obligation.cause.code() + if let ObligationCauseCode::WhereClause(_) + | ObligationCauseCode::WhereClauseInExpr(..) = obligation.cause.code() && let ty::Ref(_, ty, mutability) = old_pred.self_ty().skip_binder().kind() { ( @@ -1400,10 +1401,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if let ObligationCauseCode::ImplDerived(cause) = &*code { try_borrowing(cause.derived.parent_trait_pred, &[]) - } else if let ObligationCauseCode::SpannedItem(_, _) - | ObligationCauseCode::MiscItem(_) - | ObligationCauseCode::MiscItemInExpr(..) - | ObligationCauseCode::SpannedItemInExpr(..) = code + } else if let ObligationCauseCode::SpannedWhereClause(_, _) + | ObligationCauseCode::WhereClause(_) + | ObligationCauseCode::WhereClauseInExpr(..) + | ObligationCauseCode::SpannedWhereClauseInExpr(..) = code { try_borrowing(poly_trait_pred, &never_suggest_borrow) } else { @@ -2099,10 +2100,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: &ObligationCauseCode<'tcx>, err: &mut Diag<'tcx>, ) { - // First, look for an `SpannedItemInExpr`, which means we can get + // First, look for an `SpannedWhereClauseInExpr`, which means we can get // the uninstantiated predicate list of the called function. And check // that the predicate that we failed to satisfy is a `Fn`-like trait. - if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = cause + if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = cause && let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx) && let Some(pred) = predicates.predicates.get(*idx) && let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() @@ -2743,12 +2744,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ObligationCauseCode::TupleElem => { err.note("only the last element of a tuple may have a dynamically sized type"); } - ObligationCauseCode::MiscItem(_) | ObligationCauseCode::MiscItemInExpr(..) => { + ObligationCauseCode::WhereClause(_) | ObligationCauseCode::WhereClauseInExpr(..) => { // We hold the `DefId` of the item introducing the obligation, but displaying it // doesn't add user usable information. It always point at an associated item. } - ObligationCauseCode::SpannedItem(item_def_id, span) - | ObligationCauseCode::SpannedItemInExpr(item_def_id, span, ..) => { + ObligationCauseCode::SpannedWhereClause(item_def_id, span) + | ObligationCauseCode::SpannedWhereClauseInExpr(item_def_id, span, ..) => { let item_name = tcx.def_path_str(item_def_id); let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id)); let mut multispan = MultiSpan::from(span); @@ -3799,7 +3800,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // to an associated type (as seen from `trait_pred`) in the predicate. Like in // trait_pred `S: Sum<::Item>` and predicate `i32: Sum<&()>` let mut type_diffs = vec![]; - if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = parent_code + if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = parent_code && let Some(node_args) = typeck_results.node_args_opt(call_hir_id) && let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index f3a4e933164..de8ec17b113 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -1533,10 +1533,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { *err, ); let code = error.obligation.cause.code().peel_derives().peel_match_impls(); - if let ObligationCauseCode::SpannedItem(..) - | ObligationCauseCode::MiscItem(..) - | ObligationCauseCode::SpannedItemInExpr(..) - | ObligationCauseCode::MiscItemInExpr(..) = code + if let ObligationCauseCode::SpannedWhereClause(..) + | ObligationCauseCode::WhereClause(..) + | ObligationCauseCode::SpannedWhereClauseInExpr(..) + | ObligationCauseCode::WhereClauseInExpr(..) = code { self.note_obligation_cause_code( error.obligation.cause.body_id, @@ -1610,10 +1610,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let is_normalized_term_expected = !matches!( obligation.cause.code().peel_derives(), - ObligationCauseCode::MiscItem(_) - | ObligationCauseCode::SpannedItem(_, _) - | ObligationCauseCode::MiscItemInExpr(..) - | ObligationCauseCode::SpannedItemInExpr(..) + ObligationCauseCode::WhereClause(_) + | ObligationCauseCode::SpannedWhereClause(_, _) + | ObligationCauseCode::WhereClauseInExpr(..) + | ObligationCauseCode::SpannedWhereClauseInExpr(..) | ObligationCauseCode::Coercion { .. } ); @@ -2445,8 +2445,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - if let ObligationCauseCode::MiscItem(def_id) - | ObligationCauseCode::MiscItemInExpr(def_id, ..) = *obligation.cause.code() + if let ObligationCauseCode::WhereClause(def_id) + | ObligationCauseCode::WhereClauseInExpr(def_id, ..) = *obligation.cause.code() { self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id()); } @@ -2881,8 +2881,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { else { return; }; - let (ObligationCauseCode::SpannedItem(item_def_id, span) - | ObligationCauseCode::SpannedItemInExpr(item_def_id, span, ..)) = + let (ObligationCauseCode::SpannedWhereClause(item_def_id, span) + | ObligationCauseCode::SpannedWhereClauseInExpr(item_def_id, span, ..)) = *obligation.cause.code().peel_derives() else { return; @@ -3179,7 +3179,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ObligationCauseCode::RustCall => { err.primary_message("functions with the \"rust-call\" ABI must take a single non-self tuple argument"); } - ObligationCauseCode::SpannedItem(def_id, _) | ObligationCauseCode::MiscItem(def_id) + ObligationCauseCode::SpannedWhereClause(def_id, _) + | ObligationCauseCode::WhereClause(def_id) if self.tcx.is_fn_trait(*def_id) => { err.code(E0059); diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index e99ecff44f9..0aafc1a2efe 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -574,9 +574,9 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>( // diagnostics which is not ideal. // Consider creating separate cause codes for this specific situation. if span.is_dummy() { - ObligationCauseCode::MiscItem(alias_ty.def_id) + ObligationCauseCode::WhereClause(alias_ty.def_id) } else { - ObligationCauseCode::SpannedItem(alias_ty.def_id, span) + ObligationCauseCode::SpannedWhereClause(alias_ty.def_id, span) }, ); @@ -2123,13 +2123,13 @@ fn assoc_ty_own_obligations<'cx, 'tcx>( ObligationCause::new( obligation.cause.span, obligation.cause.body_id, - ObligationCauseCode::MiscItem(obligation.predicate.def_id), + ObligationCauseCode::WhereClause(obligation.predicate.def_id), ) } else { ObligationCause::new( obligation.cause.span, obligation.cause.body_id, - ObligationCauseCode::SpannedItem(obligation.predicate.def_id, span), + ObligationCauseCode::SpannedWhereClause(obligation.predicate.def_id, span), ) }; nested.push(Obligation::with_depth( diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index d4eb3af3b64..ebcda61f2ad 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -566,9 +566,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { iter::zip(predicates, origins.into_iter().rev()) .map(|((pred, span), origin_def_id)| { let code = if span.is_dummy() { - ObligationCauseCode::MiscItem(origin_def_id) + ObligationCauseCode::WhereClause(origin_def_id) } else { - ObligationCauseCode::SpannedItem(origin_def_id, span) + ObligationCauseCode::SpannedWhereClause(origin_def_id, span) }; let cause = self.cause(code); traits::Obligation::with_depth(