mirror of https://github.com/rust-lang/rust.git
Name tweaks
This commit is contained in:
parent
9108294a6c
commit
6f77bfe8b6
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -819,7 +819,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> 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()
|
||||
|
|
|
@ -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)
|
||||
});
|
||||
|
|
|
@ -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),
|
||||
)
|
||||
},
|
||||
);
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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..."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -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>),
|
||||
|
|
|
@ -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<<Self as Iterator>::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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue