1
Fork 0

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

@ -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),