Skip to content

Commit 9108294

Browse files
More rename fallout
1 parent 534e267 commit 9108294

File tree

25 files changed

+93
-91
lines changed

25 files changed

+93
-91
lines changed

Diff for: compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20592059
// We currently do not store the `DefId` in the `ConstraintCategory`
20602060
// for performances reasons. The error reporting code used by NLL only
20612061
// uses the span, so this doesn't cause any problems at the moment.
2062-
Some(ObligationCauseCode::Where(CRATE_DEF_ID.to_def_id(), predicate_span))
2062+
Some(ObligationCauseCode::SpannedItem(CRATE_DEF_ID.to_def_id(), predicate_span))
20632063
} else {
20642064
None
20652065
}

Diff for: compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
819819
ObligationCause::new(
820820
self.span,
821821
self.body_id,
822-
ObligationCauseCode::Where(proj.def_id, pred_span),
822+
ObligationCauseCode::SpannedItem(proj.def_id, pred_span),
823823
),
824824
self.param_env,
825825
pred,
@@ -2014,7 +2014,7 @@ pub(super) fn check_type_bounds<'tcx>(
20142014
let code = if span.is_dummy() {
20152015
ObligationCauseCode::MiscItem(trait_ty.def_id)
20162016
} else {
2017-
ObligationCauseCode::Where(trait_ty.def_id, span)
2017+
ObligationCauseCode::SpannedItem(trait_ty.def_id, span)
20182018
};
20192019
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
20202020
};
@@ -2251,7 +2251,7 @@ fn try_report_async_mismatch<'tcx>(
22512251
};
22522252

22532253
for error in errors {
2254-
if let ObligationCauseCode::Where(def_id, _) = *error.root_obligation.cause.code()
2254+
if let ObligationCauseCode::SpannedItem(def_id, _) = *error.root_obligation.cause.code()
22552255
&& def_id == async_future_def_id
22562256
&& let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred()
22572257
&& let Some(proj) = proj.no_bound_vars()

Diff for: compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn get_impl_args(
212212
traits::ObligationCause::new(
213213
impl1_span,
214214
impl1_def_id,
215-
traits::ObligationCauseCode::Where(impl2_node.def_id(), span),
215+
traits::ObligationCauseCode::SpannedItem(impl2_node.def_id(), span),
216216
)
217217
},
218218
);

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -3083,14 +3083,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30833083
polarity: ty::PredicatePolarity::Positive,
30843084
}),
30853085
|derived| {
3086-
ObligationCauseCode::ImplDerived(Box::new(
3087-
traits::ImplDerivedObligationCause {
3088-
derived,
3089-
impl_or_alias_def_id: impl_def_id,
3090-
impl_def_predicate_index: Some(idx),
3091-
span,
3092-
},
3093-
))
3086+
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
3087+
derived,
3088+
impl_or_alias_def_id: impl_def_id,
3089+
impl_def_predicate_index: Some(idx),
3090+
span,
3091+
}))
30943092
},
30953093
)
30963094
},

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14151415
if span.is_dummy() {
14161416
ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
14171417
} else {
1418-
ObligationCauseCode::WhereInExpr(def_id, span, hir_id, idx)
1418+
ObligationCauseCode::SpannedItemInExpr(def_id, span, hir_id, idx)
14191419
}
14201420
})
14211421
}

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1515
error: &mut traits::FulfillmentError<'tcx>,
1616
) -> bool {
1717
let (ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
18-
| ObligationCauseCode::WhereInExpr(def_id, _, hir_id, idx)) =
18+
| ObligationCauseCode::SpannedItemInExpr(def_id, _, hir_id, idx)) =
1919
*error.obligation.cause.code().peel_derives()
2020
else {
2121
return false;
@@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
512512
expr: &'tcx hir::Expr<'tcx>,
513513
) -> Result<&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>> {
514514
match obligation_cause_code {
515-
traits::ObligationCauseCode::WhereInExpr(_, _, _, _) => {
515+
traits::ObligationCauseCode::SpannedItemInExpr(_, _, _, _) => {
516516
// This is the "root"; we assume that the `expr` is already pointing here.
517517
// Therefore, we return `Ok` so that this `expr` can be refined further.
518518
Ok(expr)
@@ -555,7 +555,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
555555
/// only a partial success - but it cannot be refined even further.
556556
fn blame_specific_expr_if_possible_for_derived_predicate_obligation(
557557
&self,
558-
obligation: &traits::ImplDerivedObligationCause<'tcx>,
558+
obligation: &traits::ImplDerivedCause<'tcx>,
559559
expr: &'tcx hir::Expr<'tcx>,
560560
) -> Result<&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>> {
561561
// First, we attempt to refine the `expr` for our span using the parent obligation.

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_index::IndexVec;
3333
use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt};
3434
use rustc_infer::infer::TypeTrace;
3535
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
36-
use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation;
3736
use rustc_middle::ty::adjustment::AllowTwoPhase;
3837
use rustc_middle::ty::visit::TypeVisitableExt;
3938
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
@@ -2014,7 +2013,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20142013
for (span, code) in errors_causecode {
20152014
self.dcx().try_steal_modify_and_emit_err(span, StashKey::MaybeForgetReturn, |err| {
20162015
if let Some(fn_sig) = self.body_fn_sig()
2017-
&& let ExprBindingObligation(_, _, binding_hir_id, ..) = code
2016+
&& let ObligationCauseCode::SpannedItemInExpr(_, _, binding_hir_id, ..) = code
20182017
&& !fn_sig.output().is_unit()
20192018
{
20202019
let mut block_num = 0;
@@ -2103,7 +2102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21032102
//
21042103
// This is because due to normalization, we often register duplicate
21052104
// obligations with misc obligations that are basically impossible to
2106-
// line back up with a useful ExprBindingObligation.
2105+
// line back up with a useful SpannedItemInExpr.
21072106
for error in not_adjusted {
21082107
for (span, predicate, cause) in &remap_cause {
21092108
if *predicate == error.obligation.predicate

Diff for: compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
567567
let code = if span.is_dummy() {
568568
ObligationCauseCode::MiscItemInExpr(def_id, self.call_expr.hir_id, idx)
569569
} else {
570-
ObligationCauseCode::WhereInExpr(def_id, span, self.call_expr.hir_id, idx)
570+
ObligationCauseCode::SpannedItemInExpr(def_id, span, self.call_expr.hir_id, idx)
571571
};
572572
traits::ObligationCause::new(self.span, self.body_id, code)
573573
},

Diff for: compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14081408
idx,
14091409
)
14101410
} else {
1411-
ObligationCauseCode::WhereInExpr(
1411+
ObligationCauseCode::SpannedItemInExpr(
14121412
impl_def_id,
14131413
span,
14141414
self.scope_expr_id,

Diff for: compiler/rustc_hir_typeck/src/method/suggest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
830830
(data.impl_or_alias_def_id, data.span)
831831
}
832832
Some(
833-
ObligationCauseCode::WhereInExpr(def_id, span, _, _)
834-
| ObligationCauseCode::Where(def_id, span),
833+
ObligationCauseCode::SpannedItemInExpr(def_id, span, _, _)
834+
| ObligationCauseCode::SpannedItem(def_id, span),
835835
) => (*def_id, *span),
836836
_ => continue,
837837
};

Diff for: compiler/rustc_infer/src/infer/error_reporting/mod.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
883883
err.help("...or use `match` instead of `let...else`");
884884
}
885885
_ => {
886-
if let ObligationCauseCode::Where(_, span)
887-
| ObligationCauseCode::WhereInExpr(_, span, ..) = cause.code().peel_derives()
886+
if let ObligationCauseCode::SpannedItem(_, span)
887+
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
888+
cause.code().peel_derives()
888889
&& let TypeError::RegionsPlaceholderMismatch = terr
889890
{
890891
err.span_note(*span, "the lifetime requirement is introduced here");
@@ -2011,7 +2012,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20112012
trace: &TypeTrace<'tcx>,
20122013
terr: TypeError<'tcx>,
20132014
) -> Vec<TypeErrorAdditionalDiags> {
2014-
use crate::traits::ObligationCauseCode::{BlockTailExpression, MatchExpressionArm};
20152015
let mut suggestions = Vec::new();
20162016
let span = trace.cause.span();
20172017
let values = self.resolve_vars_if_possible(trace.values);
@@ -2078,8 +2078,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20782078
}
20792079
}
20802080
let code = trace.cause.code();
2081-
if let &(MatchExpressionArm(box MatchExpressionArmCause { source, .. })
2082-
| BlockTailExpression(.., source)) = code
2081+
if let &(ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
2082+
source,
2083+
..
2084+
})
2085+
| ObligationCauseCode::BlockTailExpression(.., source)) = code
20832086
&& let hir::MatchSource::TryDesugar(_) = source
20842087
&& let Some((expected_ty, found_ty, _)) = self.values_str(trace.values)
20852088
{

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3838
let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else {
3939
return None;
4040
};
41-
let (ObligationCauseCode::Where(_, binding_span)
42-
| ObligationCauseCode::WhereInExpr(_, binding_span, ..)) = *parent.code()
41+
let (ObligationCauseCode::SpannedItem(_, binding_span)
42+
| ObligationCauseCode::SpannedItemInExpr(_, binding_span, ..)) = *parent.code()
4343
else {
4444
return None;
4545
};

Diff for: compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}
44
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
55
use crate::infer::lexical_region_resolve::RegionResolutionError;
66
use crate::infer::{Subtype, ValuePairs};
7-
use crate::traits::ObligationCauseCode::CompareImplItemObligation;
87
use rustc_errors::ErrorGuaranteed;
98
use rustc_hir as hir;
109
use rustc_hir::def::Res;
1110
use rustc_hir::def_id::DefId;
1211
use rustc_hir::intravisit::Visitor;
1312
use rustc_middle::hir::nested_filter;
13+
use rustc_middle::traits::ObligationCauseCode;
1414
use rustc_middle::ty::error::ExpectedFound;
1515
use rustc_middle::ty::print::RegionHighlightMode;
1616
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
@@ -31,7 +31,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3131
_,
3232
) = error.clone()
3333
&& let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin)
34-
&& let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code()
34+
&& let ObligationCauseCode::CompareImplItem { trait_item_def_id, .. } =
35+
sub_trace.cause.code()
3536
&& sub_trace.values == sup_trace.values
3637
&& let ValuePairs::PolySigs(ExpectedFound { expected, found }) = sub_trace.values
3738
{

Diff for: compiler/rustc_infer/src/infer/error_reporting/note.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
357357
infer::Subtype(box ref trace)
358358
if matches!(
359359
&trace.cause.code().peel_derives(),
360-
ObligationCauseCode::Where(..) | ObligationCauseCode::WhereInExpr(..)
360+
ObligationCauseCode::SpannedItem(..)
361+
| ObligationCauseCode::SpannedItemInExpr(..)
361362
) =>
362363
{
363364
// Hack to get around the borrow checker because trace.cause has an `Rc`.
364-
if let ObligationCauseCode::Where(_, span)
365-
| ObligationCauseCode::WhereInExpr(_, span, ..) =
365+
if let ObligationCauseCode::SpannedItem(_, span)
366+
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
366367
&trace.cause.code().peel_derives()
367368
{
368369
let span = *span;
369370
self.report_concrete_failure(placeholder_origin, sub, sup)
370371
.with_span_note(span, "the lifetime requirement is introduced here")
371372
} else {
372373
unreachable!(
373-
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
374+
"control flow ensures we have a `BindingObligation` or `SpannedItemInExpr` here..."
374375
)
375376
}
376377
}

Diff for: compiler/rustc_infer/src/infer/outlives/obligations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ impl<'tcx> InferCtxt<'tcx> {
103103
cause.span,
104104
sup_type,
105105
match cause.code().peel_derives() {
106-
ObligationCauseCode::Where(_, span)
107-
| ObligationCauseCode::WhereInExpr(_, span, ..) => Some(*span),
106+
ObligationCauseCode::SpannedItem(_, span)
107+
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) => Some(*span),
108108
_ => None,
109109
},
110110
)

Diff for: compiler/rustc_infer/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> PredicateObligation<'tcx> {
105105
impl<'tcx> PolyTraitObligation<'tcx> {
106106
pub fn derived_cause(
107107
&self,
108-
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
108+
variant: impl FnOnce(DerivedCause<'tcx>) -> ObligationCauseCode<'tcx>,
109109
) -> ObligationCause<'tcx> {
110110
self.cause.clone().derived_cause(self.predicate, variant)
111111
}

Diff for: compiler/rustc_infer/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
129129
index: usize,
130130
) -> Self {
131131
let cause = self.cause.clone().derived_cause(parent_trait_pred, |derived| {
132-
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedObligationCause {
132+
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
133133
derived,
134134
impl_or_alias_def_id: parent_trait_pred.def_id(),
135135
impl_def_predicate_index: Some(index),

Diff for: compiler/rustc_middle/src/traits/mod.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'tcx> ObligationCause<'tcx> {
165165
pub fn derived_cause(
166166
mut self,
167167
parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
168-
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
168+
variant: impl FnOnce(DerivedCause<'tcx>) -> ObligationCauseCode<'tcx>,
169169
) -> ObligationCause<'tcx> {
170170
/*!
171171
* Creates a cause for obligations that are derived from
@@ -180,8 +180,7 @@ impl<'tcx> ObligationCause<'tcx> {
180180
// NOTE(flaper87): As of now, it keeps track of the whole error
181181
// chain. Ideally, we should have a way to configure this either
182182
// by using -Z verbose-internals or just a CLI argument.
183-
self.code =
184-
variant(DerivedObligationCause { parent_trait_pred, parent_code: self.code }).into();
183+
self.code = variant(DerivedCause { parent_trait_pred, parent_code: self.code }).into();
185184
self
186185
}
187186

@@ -254,16 +253,16 @@ pub enum ObligationCauseCode<'tcx> {
254253

255254
/// Like `MiscItem`, but carries the span of the
256255
/// predicate when it can be identified.
257-
Where(DefId, Span),
256+
SpannedItem(DefId, Span),
258257

259-
/// Like `ItemObligation`, but carries the `HirId` of the
258+
/// Like `MiscItem`, but carries the `HirId` of the
260259
/// expression that caused the obligation, and the `usize`
261260
/// indicates exactly which predicate it is in the list of
262261
/// instantiated predicates.
263262
MiscItemInExpr(DefId, HirId, usize),
264263

265-
/// Combines `ExprItemObligation` and `BindingObligation`.
266-
WhereInExpr(DefId, Span, HirId, usize),
264+
/// Combines `SpannedItem` and `MiscItemInExpr`.
265+
SpannedItemInExpr(DefId, Span, HirId, usize),
267266

268267
/// A type like `&'a T` is WF only if `T: 'a`.
269268
ReferenceOutlivesReferent(Ty<'tcx>),
@@ -327,16 +326,18 @@ pub enum ObligationCauseCode<'tcx> {
327326

328327
/// Derived obligation (i.e. theoretical `where` clause) on a built-in
329328
/// implementation like `Copy` or `Sized`.
330-
BuiltinDerived(DerivedObligationCause<'tcx>),
329+
BuiltinDerived(DerivedCause<'tcx>),
331330

332331
/// Derived obligation (i.e. `where` clause) on an user-provided impl
333332
/// or a trait alias.
334-
ImplDerived(Box<ImplDerivedObligationCause<'tcx>>),
333+
ImplDerived(Box<ImplDerivedCause<'tcx>>),
335334

336335
/// Derived obligation for WF goals.
337-
WellFormedDerived(DerivedObligationCause<'tcx>),
336+
WellFormedDerived(DerivedCause<'tcx>),
338337

339-
FunctionArgumentObligation {
338+
/// Derived obligation refined to point at a specific argument in
339+
/// a call or method expression.
340+
FunctionArg {
340341
/// The node of the relevant argument in the function call.
341342
arg_hir_id: HirId,
342343
/// The node of the function call.
@@ -347,7 +348,7 @@ pub enum ObligationCauseCode<'tcx> {
347348

348349
/// Error derived when checking an impl item is compatible with
349350
/// its corresponding trait item's definition
350-
CompareImplItemObligation {
351+
CompareImplItem {
351352
impl_item_def_id: LocalDefId,
352353
trait_item_def_id: DefId,
353354
kind: ty::AssocKind,
@@ -495,8 +496,8 @@ pub enum WellFormedLoc {
495496

496497
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
497498
#[derive(TypeVisitable, TypeFoldable)]
498-
pub struct ImplDerivedObligationCause<'tcx> {
499-
pub derived: DerivedObligationCause<'tcx>,
499+
pub struct ImplDerivedCause<'tcx> {
500+
pub derived: DerivedCause<'tcx>,
500501
/// The `DefId` of the `impl` that gave rise to the `derived` obligation.
501502
/// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic impl,
502503
/// 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> {
537538
ObligationCauseCode::FunctionArg { parent_code, .. } => Some((parent_code, None)),
538539
ObligationCauseCode::BuiltinDerived(derived)
539540
| ObligationCauseCode::WellFormedDerived(derived)
540-
| ObligationCauseCode::ImplDerived(box ImplDerivedObligationCause {
541-
derived, ..
542-
}) => Some((&derived.parent_code, Some(derived.parent_trait_pred))),
541+
| ObligationCauseCode::ImplDerived(box ImplDerivedCause { derived, .. }) => {
542+
Some((&derived.parent_code, Some(derived.parent_trait_pred)))
543+
}
543544
_ => None,
544545
}
545546
}
@@ -592,7 +593,7 @@ pub struct IfExpressionCause<'tcx> {
592593

593594
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
594595
#[derive(TypeVisitable, TypeFoldable)]
595-
pub struct DerivedObligationCause<'tcx> {
596+
pub struct DerivedCause<'tcx> {
596597
/// The trait predicate of the parent obligation that led to the
597598
/// current obligation. Note that only trait obligations lead to
598599
/// derived obligations, so we just store the trait predicate here

0 commit comments

Comments
 (0)