More rename fallout

This commit is contained in:
Michael Goulet 2024-05-09 20:25:11 -04:00
parent 534e267d48
commit 9108294a6c
25 changed files with 93 additions and 91 deletions

View File

@ -2059,7 +2059,7 @@ 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::Where(CRATE_DEF_ID.to_def_id(), predicate_span))
Some(ObligationCauseCode::SpannedItem(CRATE_DEF_ID.to_def_id(), predicate_span))
} else {
None
}

View File

@ -819,7 +819,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
ObligationCause::new(
self.span,
self.body_id,
ObligationCauseCode::Where(proj.def_id, pred_span),
ObligationCauseCode::SpannedItem(proj.def_id, pred_span),
),
self.param_env,
pred,
@ -2014,7 +2014,7 @@ pub(super) fn check_type_bounds<'tcx>(
let code = if span.is_dummy() {
ObligationCauseCode::MiscItem(trait_ty.def_id)
} else {
ObligationCauseCode::Where(trait_ty.def_id, span)
ObligationCauseCode::SpannedItem(trait_ty.def_id, span)
};
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
};
@ -2251,7 +2251,7 @@ fn try_report_async_mismatch<'tcx>(
};
for error in errors {
if let ObligationCauseCode::Where(def_id, _) = *error.root_obligation.cause.code()
if let ObligationCauseCode::SpannedItem(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()

View File

@ -212,7 +212,7 @@ fn get_impl_args(
traits::ObligationCause::new(
impl1_span,
impl1_def_id,
traits::ObligationCauseCode::Where(impl2_node.def_id(), span),
traits::ObligationCauseCode::SpannedItem(impl2_node.def_id(), span),
)
},
);

View File

@ -3083,14 +3083,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
polarity: ty::PredicatePolarity::Positive,
}),
|derived| {
ObligationCauseCode::ImplDerived(Box::new(
traits::ImplDerivedObligationCause {
derived,
impl_or_alias_def_id: impl_def_id,
impl_def_predicate_index: Some(idx),
span,
},
))
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
derived,
impl_or_alias_def_id: impl_def_id,
impl_def_predicate_index: Some(idx),
span,
}))
},
)
},

View File

@ -1415,7 +1415,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if span.is_dummy() {
ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
} else {
ObligationCauseCode::WhereInExpr(def_id, span, hir_id, idx)
ObligationCauseCode::SpannedItemInExpr(def_id, span, hir_id, idx)
}
})
}

View File

@ -15,7 +15,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error: &mut traits::FulfillmentError<'tcx>,
) -> bool {
let (ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
| ObligationCauseCode::WhereInExpr(def_id, _, hir_id, idx)) =
| ObligationCauseCode::SpannedItemInExpr(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::WhereInExpr(_, _, _, _) => {
traits::ObligationCauseCode::SpannedItemInExpr(_, _, _, _) => {
// 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)
@ -555,7 +555,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// only a partial success - but it cannot be refined even further.
fn blame_specific_expr_if_possible_for_derived_predicate_obligation(
&self,
obligation: &traits::ImplDerivedObligationCause<'tcx>,
obligation: &traits::ImplDerivedCause<'tcx>,
expr: &'tcx hir::Expr<'tcx>,
) -> Result<&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>> {
// First, we attempt to refine the `expr` for our span using the parent obligation.

View File

@ -33,7 +33,6 @@ use rustc_index::IndexVec;
use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt};
use rustc_infer::infer::TypeTrace;
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation;
use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::visit::TypeVisitableExt;
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
@ -2014,7 +2013,7 @@ 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 ExprBindingObligation(_, _, binding_hir_id, ..) = code
&& let ObligationCauseCode::SpannedItemInExpr(_, _, binding_hir_id, ..) = code
&& !fn_sig.output().is_unit()
{
let mut block_num = 0;
@ -2103,7 +2102,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 ExprBindingObligation.
// line back up with a useful SpannedItemInExpr.
for error in not_adjusted {
for (span, predicate, cause) in &remap_cause {
if *predicate == error.obligation.predicate

View File

@ -567,7 +567,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
let code = if span.is_dummy() {
ObligationCauseCode::MiscItemInExpr(def_id, self.call_expr.hir_id, idx)
} else {
ObligationCauseCode::WhereInExpr(def_id, span, self.call_expr.hir_id, idx)
ObligationCauseCode::SpannedItemInExpr(def_id, span, self.call_expr.hir_id, idx)
};
traits::ObligationCause::new(self.span, self.body_id, code)
},

View File

@ -1408,7 +1408,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
idx,
)
} else {
ObligationCauseCode::WhereInExpr(
ObligationCauseCode::SpannedItemInExpr(
impl_def_id,
span,
self.scope_expr_id,

View File

@ -830,8 +830,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(data.impl_or_alias_def_id, data.span)
}
Some(
ObligationCauseCode::WhereInExpr(def_id, span, _, _)
| ObligationCauseCode::Where(def_id, span),
ObligationCauseCode::SpannedItemInExpr(def_id, span, _, _)
| ObligationCauseCode::SpannedItem(def_id, span),
) => (*def_id, *span),
_ => continue,
};

View File

@ -883,8 +883,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
err.help("...or use `match` instead of `let...else`");
}
_ => {
if let ObligationCauseCode::Where(_, span)
| ObligationCauseCode::WhereInExpr(_, span, ..) = cause.code().peel_derives()
if let ObligationCauseCode::SpannedItem(_, span)
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
cause.code().peel_derives()
&& let TypeError::RegionsPlaceholderMismatch = terr
{
err.span_note(*span, "the lifetime requirement is introduced here");
@ -2011,7 +2012,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
trace: &TypeTrace<'tcx>,
terr: TypeError<'tcx>,
) -> Vec<TypeErrorAdditionalDiags> {
use crate::traits::ObligationCauseCode::{BlockTailExpression, MatchExpressionArm};
let mut suggestions = Vec::new();
let span = trace.cause.span();
let values = self.resolve_vars_if_possible(trace.values);
@ -2078,8 +2078,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}
let code = trace.cause.code();
if let &(MatchExpressionArm(box MatchExpressionArmCause { source, .. })
| BlockTailExpression(.., source)) = code
if let &(ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
source,
..
})
| ObligationCauseCode::BlockTailExpression(.., source)) = code
&& let hir::MatchSource::TryDesugar(_) = source
&& let Some((expected_ty, found_ty, _)) = self.values_str(trace.values)
{

View File

@ -38,8 +38,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else {
return None;
};
let (ObligationCauseCode::Where(_, binding_span)
| ObligationCauseCode::WhereInExpr(_, binding_span, ..)) = *parent.code()
let (ObligationCauseCode::SpannedItem(_, binding_span)
| ObligationCauseCode::SpannedItemInExpr(_, binding_span, ..)) = *parent.code()
else {
return None;
};

View File

@ -4,13 +4,13 @@ use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{Subtype, ValuePairs};
use crate::traits::ObligationCauseCode::CompareImplItemObligation;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_middle::hir::nested_filter;
use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
@ -31,7 +31,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
_,
) = error.clone()
&& let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin)
&& let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code()
&& let ObligationCauseCode::CompareImplItem { trait_item_def_id, .. } =
sub_trace.cause.code()
&& sub_trace.values == sup_trace.values
&& let ValuePairs::PolySigs(ExpectedFound { expected, found }) = sub_trace.values
{

View File

@ -357,12 +357,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
infer::Subtype(box ref trace)
if matches!(
&trace.cause.code().peel_derives(),
ObligationCauseCode::Where(..) | ObligationCauseCode::WhereInExpr(..)
ObligationCauseCode::SpannedItem(..)
| ObligationCauseCode::SpannedItemInExpr(..)
) =>
{
// Hack to get around the borrow checker because trace.cause has an `Rc`.
if let ObligationCauseCode::Where(_, span)
| ObligationCauseCode::WhereInExpr(_, span, ..) =
if let ObligationCauseCode::SpannedItem(_, span)
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
&trace.cause.code().peel_derives()
{
let span = *span;
@ -370,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 `ExprBindingObligation` here..."
"control flow ensures we have a `BindingObligation` or `SpannedItemInExpr` here..."
)
}
}

View File

@ -103,8 +103,8 @@ impl<'tcx> InferCtxt<'tcx> {
cause.span,
sup_type,
match cause.code().peel_derives() {
ObligationCauseCode::Where(_, span)
| ObligationCauseCode::WhereInExpr(_, span, ..) => Some(*span),
ObligationCauseCode::SpannedItem(_, span)
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) => Some(*span),
_ => None,
},
)

View File

@ -105,7 +105,7 @@ impl<'tcx> PredicateObligation<'tcx> {
impl<'tcx> PolyTraitObligation<'tcx> {
pub fn derived_cause(
&self,
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
variant: impl FnOnce(DerivedCause<'tcx>) -> ObligationCauseCode<'tcx>,
) -> ObligationCause<'tcx> {
self.cause.clone().derived_cause(self.predicate, variant)
}

View File

@ -129,7 +129,7 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
index: usize,
) -> Self {
let cause = self.cause.clone().derived_cause(parent_trait_pred, |derived| {
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedObligationCause {
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
derived,
impl_or_alias_def_id: parent_trait_pred.def_id(),
impl_def_predicate_index: Some(index),

View File

@ -165,7 +165,7 @@ impl<'tcx> ObligationCause<'tcx> {
pub fn derived_cause(
mut self,
parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
variant: impl FnOnce(DerivedCause<'tcx>) -> ObligationCauseCode<'tcx>,
) -> ObligationCause<'tcx> {
/*!
* Creates a cause for obligations that are derived from
@ -180,8 +180,7 @@ impl<'tcx> ObligationCause<'tcx> {
// NOTE(flaper87): As of now, it keeps track of the whole error
// chain. Ideally, we should have a way to configure this either
// by using -Z verbose-internals or just a CLI argument.
self.code =
variant(DerivedObligationCause { parent_trait_pred, parent_code: self.code }).into();
self.code = variant(DerivedCause { parent_trait_pred, parent_code: self.code }).into();
self
}
@ -254,16 +253,16 @@ pub enum ObligationCauseCode<'tcx> {
/// Like `MiscItem`, but carries the span of the
/// predicate when it can be identified.
Where(DefId, Span),
SpannedItem(DefId, Span),
/// Like `ItemObligation`, but carries the `HirId` of the
/// Like `MiscItem`, 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),
/// Combines `ExprItemObligation` and `BindingObligation`.
WhereInExpr(DefId, Span, HirId, usize),
/// Combines `SpannedItem` and `MiscItemInExpr`.
SpannedItemInExpr(DefId, Span, HirId, usize),
/// A type like `&'a T` is WF only if `T: 'a`.
ReferenceOutlivesReferent(Ty<'tcx>),
@ -327,16 +326,18 @@ pub enum ObligationCauseCode<'tcx> {
/// Derived obligation (i.e. theoretical `where` clause) on a built-in
/// implementation like `Copy` or `Sized`.
BuiltinDerived(DerivedObligationCause<'tcx>),
BuiltinDerived(DerivedCause<'tcx>),
/// Derived obligation (i.e. `where` clause) on an user-provided impl
/// or a trait alias.
ImplDerived(Box<ImplDerivedObligationCause<'tcx>>),
ImplDerived(Box<ImplDerivedCause<'tcx>>),
/// Derived obligation for WF goals.
WellFormedDerived(DerivedObligationCause<'tcx>),
WellFormedDerived(DerivedCause<'tcx>),
FunctionArgumentObligation {
/// Derived obligation refined to point at a specific argument in
/// a call or method expression.
FunctionArg {
/// The node of the relevant argument in the function call.
arg_hir_id: HirId,
/// The node of the function call.
@ -347,7 +348,7 @@ pub enum ObligationCauseCode<'tcx> {
/// Error derived when checking an impl item is compatible with
/// its corresponding trait item's definition
CompareImplItemObligation {
CompareImplItem {
impl_item_def_id: LocalDefId,
trait_item_def_id: DefId,
kind: ty::AssocKind,
@ -495,8 +496,8 @@ pub enum WellFormedLoc {
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
#[derive(TypeVisitable, TypeFoldable)]
pub struct ImplDerivedObligationCause<'tcx> {
pub derived: DerivedObligationCause<'tcx>,
pub struct ImplDerivedCause<'tcx> {
pub derived: DerivedCause<'tcx>,
/// The `DefId` of the `impl` that gave rise to the `derived` obligation.
/// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic impl,
/// then this will be the `DefId` of that trait alias. Care should therefore be taken to handle
@ -537,9 +538,9 @@ impl<'tcx> ObligationCauseCode<'tcx> {
ObligationCauseCode::FunctionArg { parent_code, .. } => Some((parent_code, None)),
ObligationCauseCode::BuiltinDerived(derived)
| ObligationCauseCode::WellFormedDerived(derived)
| ObligationCauseCode::ImplDerived(box ImplDerivedObligationCause {
derived, ..
}) => Some((&derived.parent_code, Some(derived.parent_trait_pred))),
| ObligationCauseCode::ImplDerived(box ImplDerivedCause { derived, .. }) => {
Some((&derived.parent_code, Some(derived.parent_trait_pred)))
}
_ => None,
}
}
@ -592,7 +593,7 @@ pub struct IfExpressionCause<'tcx> {
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
#[derive(TypeVisitable, TypeFoldable)]
pub struct DerivedObligationCause<'tcx> {
pub struct DerivedCause<'tcx> {
/// The trait predicate of the parent obligation that led to the
/// current obligation. Note that only trait obligations lead to
/// derived obligations, so we just store the trait predicate here

View File

@ -425,7 +425,7 @@ fn derive_cause<'tcx>(
tcx.predicates_of(impl_def_id).instantiate_identity(tcx).iter().nth(idx)
{
cause = cause.derived_cause(parent_trait_pred, |derived| {
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedObligationCause {
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
derived,
impl_or_alias_def_id: impl_def_id,
impl_def_predicate_index: Some(idx),
@ -435,8 +435,7 @@ fn derive_cause<'tcx>(
}
}
ProbeKind::TraitCandidate { source: CandidateSource::BuiltinImpl(..), result: _ } => {
cause = cause
.derived_cause(parent_trait_pred, ObligationCauseCode::BuiltinDerivedObligation);
cause = cause.derived_cause(parent_trait_pred, ObligationCauseCode::BuiltinDerived);
}
_ => {}
};

View File

@ -7,7 +7,7 @@ use super::{
use crate::errors;
use crate::infer::InferCtxt;
use crate::traits::{ImplDerivedObligationCause, NormalizeExt, ObligationCtxt};
use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt};
use hir::def::CtorOf;
use rustc_data_structures::fx::FxHashSet;
@ -1400,10 +1400,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if let ObligationCauseCode::ImplDerived(cause) = &*code {
try_borrowing(cause.derived.parent_trait_pred, &[])
} else if let ObligationCauseCode::Where(_, _)
} else if let ObligationCauseCode::SpannedItem(_, _)
| ObligationCauseCode::MiscItem(_)
| ObligationCauseCode::MiscItemInExpr(..)
| ObligationCauseCode::WhereInExpr(..) = code
| ObligationCauseCode::SpannedItemInExpr(..) = code
{
try_borrowing(poly_trait_pred, &never_suggest_borrow)
} else {
@ -2099,10 +2099,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
cause: &ObligationCauseCode<'tcx>,
err: &mut Diag<'tcx>,
) {
// First, look for an `ExprBindingObligation`, which means we can get
// First, look for an `SpannedItemInExpr`, 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::WhereInExpr(def_id, _, _, idx) = cause
if let ObligationCauseCode::SpannedItemInExpr(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()
@ -2747,8 +2747,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// 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::Where(item_def_id, span)
| ObligationCauseCode::WhereInExpr(item_def_id, span, ..) => {
ObligationCauseCode::SpannedItem(item_def_id, span)
| ObligationCauseCode::SpannedItemInExpr(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 +3799,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// to an associated type (as seen from `trait_pred`) in the predicate. Like in
// trait_pred `S: Sum<<Self as Iterator>::Item>` and predicate `i32: Sum<&()>`
let mut type_diffs = vec![];
if let ObligationCauseCode::WhereInExpr(def_id, _, _, idx) = parent_code
if let ObligationCauseCode::SpannedItemInExpr(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)
@ -4955,7 +4955,7 @@ fn point_at_assoc_type_restriction<G: EmissionGuarantee>(
trait_name: &str,
predicate: ty::Predicate<'_>,
generics: &hir::Generics<'_>,
data: &ImplDerivedObligationCause<'_>,
data: &ImplDerivedCause<'_>,
) {
let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder() else {
return;

View File

@ -1533,9 +1533,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
*err,
);
let code = error.obligation.cause.code().peel_derives().peel_match_impls();
if let ObligationCauseCode::Where(..)
if let ObligationCauseCode::SpannedItem(..)
| ObligationCauseCode::MiscItem(..)
| ObligationCauseCode::WhereInExpr(..)
| ObligationCauseCode::SpannedItemInExpr(..)
| ObligationCauseCode::MiscItemInExpr(..) = code
{
self.note_obligation_cause_code(
@ -1611,9 +1611,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let is_normalized_term_expected = !matches!(
obligation.cause.code().peel_derives(),
ObligationCauseCode::MiscItem(_)
| ObligationCauseCode::Where(_, _)
| ObligationCauseCode::SpannedItem(_, _)
| ObligationCauseCode::MiscItemInExpr(..)
| ObligationCauseCode::WhereInExpr(..)
| ObligationCauseCode::SpannedItemInExpr(..)
| ObligationCauseCode::Coercion { .. }
);
@ -2881,8 +2881,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
else {
return;
};
let (ObligationCauseCode::Where(item_def_id, span)
| ObligationCauseCode::WhereInExpr(item_def_id, span, ..)) =
let (ObligationCauseCode::SpannedItem(item_def_id, span)
| ObligationCauseCode::SpannedItemInExpr(item_def_id, span, ..)) =
*obligation.cause.code().peel_derives()
else {
return;
@ -3179,7 +3179,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
ObligationCauseCode::RustCall => {
err.primary_message("functions with the \"rust-call\" ABI must take a single non-self tuple argument");
}
ObligationCauseCode::Where(def_id, _) | ObligationCauseCode::MiscItem(def_id)
ObligationCauseCode::SpannedItem(def_id, _) | ObligationCauseCode::MiscItem(def_id)
if self.tcx.is_fn_trait(*def_id) =>
{
err.code(E0059);

View File

@ -576,7 +576,7 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>(
if span.is_dummy() {
ObligationCauseCode::MiscItem(alias_ty.def_id)
} else {
ObligationCauseCode::Where(alias_ty.def_id, span)
ObligationCauseCode::SpannedItem(alias_ty.def_id, span)
},
);
@ -2129,7 +2129,7 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
ObligationCause::new(
obligation.cause.span,
obligation.cause.body_id,
ObligationCauseCode::Where(obligation.predicate.def_id, span),
ObligationCauseCode::SpannedItem(obligation.predicate.def_id, span),
)
};
nested.push(Obligation::with_depth(

View File

@ -26,7 +26,7 @@ use crate::traits::vtable::{
VtblSegment,
};
use crate::traits::{
ImplDerivedObligationCause, ImplSource, ImplSourceUserDefinedData, Normalized, Obligation,
ImplDerivedCause, ImplSource, ImplSourceUserDefinedData, Normalized, Obligation,
ObligationCause, PolyTraitObligation, PredicateObligation, Selection, SelectionError,
SignatureMismatch, TraitNotObjectSafe, TraitObligation, Unimplemented,
};
@ -275,7 +275,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
bug!("obligation {:?} had matched a builtin impl but now doesn't", obligation);
};
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerivedObligation);
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
self.collect_predicates_for_types(
obligation.param_env,
cause,
@ -435,7 +435,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
) -> Vec<PredicateObligation<'tcx>> {
debug!(?nested, "vtable_auto_impl");
ensure_sufficient_stack(|| {
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerivedObligation);
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
let trait_ref = self.infcx.enter_forall_and_leak_universe(poly_trait_ref);
@ -723,7 +723,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let mut nested =
self.equate_trait_refs(obligation.with(tcx, placeholder_predicate), trait_ref)?;
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerivedObligation);
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
let output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
@ -1381,7 +1381,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let self_ty = obligation.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
let mut nested = vec![];
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerivedObligation);
let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived);
// If we have a custom `impl const Drop`, then
// first check it like a regular impl candidate.
@ -1396,7 +1396,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!(?args, "impl args");
let cause = obligation.derived_cause(|derived| {
ObligationCauseCode::ImplDerived(Box::new(ImplDerivedObligationCause {
ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
derived,
impl_or_alias_def_id: impl_def_id,
impl_def_predicate_index: None,

View File

@ -13,8 +13,8 @@ use super::util;
use super::util::closure_trait_ref_and_return_type;
use super::wf;
use super::{
ImplDerivedObligationCause, Normalized, Obligation, ObligationCause, ObligationCauseCode,
Overflow, PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode, Overflow,
PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
TraitQueryMode,
};
@ -2771,7 +2771,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
cause.clone()
} else {
cause.clone().derived_cause(parent_trait_pred, |derived| {
ObligationCauseCode::ImplDerived(Box::new(ImplDerivedObligationCause {
ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause {
derived,
impl_or_alias_def_id: def_id,
impl_def_predicate_index: Some(index),

View File

@ -382,7 +382,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
if let Some(parent_trait_pred) = predicate.to_opt_poly_trait_pred() {
cause = cause.derived_cause(
parent_trait_pred,
traits::ObligationCauseCode::WellFormedDerivedObligation,
traits::ObligationCauseCode::WellFormedDerived,
);
}
extend_cause_with_original_assoc_item_obligation(tcx, item, &mut cause, predicate);
@ -568,7 +568,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
let code = if span.is_dummy() {
ObligationCauseCode::MiscItem(origin_def_id)
} else {
ObligationCauseCode::Where(origin_def_id, span)
ObligationCauseCode::SpannedItem(origin_def_id, span)
};
let cause = self.cause(code);
traits::Obligation::with_depth(