Skip to content

Commit 534e267

Browse files
Rename some ObligationCauseCode variants
1 parent 4bde8a8 commit 534e267

File tree

33 files changed

+187
-247
lines changed

33 files changed

+187
-247
lines changed

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -2059,15 +2059,12 @@ 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::BindingObligation(
2063-
CRATE_DEF_ID.to_def_id(),
2064-
predicate_span,
2065-
))
2062+
Some(ObligationCauseCode::Where(CRATE_DEF_ID.to_def_id(), predicate_span))
20662063
} else {
20672064
None
20682065
}
20692066
})
2070-
.unwrap_or_else(|| ObligationCauseCode::MiscObligation);
2067+
.unwrap_or_else(|| ObligationCauseCode::Misc);
20712068

20722069
// Classify each of the constraints along the path.
20732070
let mut categorized_path: Vec<BlameConstraint<'tcx>> = path

Diff for: compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
738738
let cause = ObligationCause::new(
739739
terminator.source_info.span,
740740
self.body.source.def_id().expect_local(),
741-
ObligationCauseCode::ItemObligation(callee),
741+
ObligationCauseCode::MiscItem(callee),
742742
);
743743
let normalized_predicates = ocx.normalize(&cause, param_env, predicates);
744744
ocx.register_obligations(traits::predicates_for_generics(

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

+9-10
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn compare_method_predicate_entailment<'tcx>(
175175
let cause = ObligationCause::new(
176176
impl_m_span,
177177
impl_m_def_id,
178-
ObligationCauseCode::CompareImplItemObligation {
178+
ObligationCauseCode::CompareImplItem {
179179
impl_item_def_id: impl_m_def_id,
180180
trait_item_def_id: trait_m.def_id,
181181
kind: impl_m.kind,
@@ -236,7 +236,7 @@ fn compare_method_predicate_entailment<'tcx>(
236236
let cause = ObligationCause::new(
237237
span,
238238
impl_m_def_id,
239-
ObligationCauseCode::CompareImplItemObligation {
239+
ObligationCauseCode::CompareImplItem {
240240
impl_item_def_id: impl_m_def_id,
241241
trait_item_def_id: trait_m.def_id,
242242
kind: impl_m.kind,
@@ -464,7 +464,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
464464
let cause = ObligationCause::new(
465465
return_span,
466466
impl_m_def_id,
467-
ObligationCauseCode::CompareImplItemObligation {
467+
ObligationCauseCode::CompareImplItem {
468468
impl_item_def_id: impl_m_def_id,
469469
trait_item_def_id: trait_m.def_id,
470470
kind: impl_m.kind,
@@ -819,7 +819,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
819819
ObligationCause::new(
820820
self.span,
821821
self.body_id,
822-
ObligationCauseCode::BindingObligation(proj.def_id, pred_span),
822+
ObligationCauseCode::Where(proj.def_id, pred_span),
823823
),
824824
self.param_env,
825825
pred,
@@ -1752,7 +1752,7 @@ fn compare_const_predicate_entailment<'tcx>(
17521752
let impl_ty = tcx.type_of(impl_ct_def_id).instantiate_identity();
17531753

17541754
let trait_ty = tcx.type_of(trait_ct.def_id).instantiate(tcx, trait_to_impl_args);
1755-
let code = ObligationCauseCode::CompareImplItemObligation {
1755+
let code = ObligationCauseCode::CompareImplItem {
17561756
impl_item_def_id: impl_ct_def_id,
17571757
trait_item_def_id: trait_ct.def_id,
17581758
kind: impl_ct.kind,
@@ -1924,7 +1924,7 @@ fn compare_type_predicate_entailment<'tcx>(
19241924
let cause = ObligationCause::new(
19251925
span,
19261926
impl_ty_def_id,
1927-
ObligationCauseCode::CompareImplItemObligation {
1927+
ObligationCauseCode::CompareImplItem {
19281928
impl_item_def_id: impl_ty.def_id.expect_local(),
19291929
trait_item_def_id: trait_ty.def_id,
19301930
kind: impl_ty.kind,
@@ -2012,9 +2012,9 @@ pub(super) fn check_type_bounds<'tcx>(
20122012
);
20132013
let mk_cause = |span: Span| {
20142014
let code = if span.is_dummy() {
2015-
ObligationCauseCode::ItemObligation(trait_ty.def_id)
2015+
ObligationCauseCode::MiscItem(trait_ty.def_id)
20162016
} else {
2017-
ObligationCauseCode::BindingObligation(trait_ty.def_id, span)
2017+
ObligationCauseCode::Where(trait_ty.def_id, span)
20182018
};
20192019
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
20202020
};
@@ -2251,8 +2251,7 @@ fn try_report_async_mismatch<'tcx>(
22512251
};
22522252

22532253
for error in errors {
2254-
if let ObligationCauseCode::BindingObligation(def_id, _) =
2255-
*error.root_obligation.cause.code()
2254+
if let ObligationCauseCode::Where(def_id, _) = *error.root_obligation.cause.code()
22562255
&& def_id == async_future_def_id
22572256
&& let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred()
22582257
&& let Some(proj) = proj.no_bound_vars()

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ fn check_type_defn<'tcx>(
11611161
let cause = traits::ObligationCause::new(
11621162
tcx.def_span(discr_def_id),
11631163
wfcx.body_def_id,
1164-
ObligationCauseCode::MiscObligation,
1164+
ObligationCauseCode::Misc,
11651165
);
11661166
wfcx.register_obligation(traits::Obligation::new(
11671167
tcx,
@@ -1550,7 +1550,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
15501550
let cause = traits::ObligationCause::new(
15511551
sp,
15521552
wfcx.body_def_id,
1553-
ObligationCauseCode::ItemObligation(def_id.to_def_id()),
1553+
ObligationCauseCode::MiscItem(def_id.to_def_id()),
15541554
);
15551555
traits::Obligation::new(tcx, cause, wfcx.param_env, pred)
15561556
});

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::BindingObligation(impl2_node.def_id(), span),
215+
traits::ObligationCauseCode::Where(impl2_node.def_id(), span),
216216
)
217217
},
218218
);

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

+4-16
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30833083
polarity: ty::PredicatePolarity::Positive,
30843084
}),
30853085
|derived| {
3086-
ObligationCauseCode::ImplDerivedObligation(Box::new(
3086+
ObligationCauseCode::ImplDerived(Box::new(
30873087
traits::ImplDerivedObligationCause {
30883088
derived,
30893089
impl_or_alias_def_id: impl_def_id,
@@ -3352,11 +3352,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33523352
let field_ty = self.field_ty(expr.span, field, args);
33533353

33543354
// FIXME: DSTs with static alignment should be allowed
3355-
self.require_type_is_sized(
3356-
field_ty,
3357-
expr.span,
3358-
ObligationCauseCode::MiscObligation,
3359-
);
3355+
self.require_type_is_sized(field_ty, expr.span, ObligationCauseCode::Misc);
33603356

33613357
if field.vis.is_accessible_from(sub_def_scope, self.tcx) {
33623358
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
@@ -3384,11 +3380,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33843380
let field_ty = self.field_ty(expr.span, field, args);
33853381

33863382
// FIXME: DSTs with static alignment should be allowed
3387-
self.require_type_is_sized(
3388-
field_ty,
3389-
expr.span,
3390-
ObligationCauseCode::MiscObligation,
3391-
);
3383+
self.require_type_is_sized(field_ty, expr.span, ObligationCauseCode::Misc);
33923384

33933385
if field.vis.is_accessible_from(def_scope, self.tcx) {
33943386
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
@@ -3409,11 +3401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34093401
&& field.name == sym::integer(index)
34103402
{
34113403
for ty in tys.iter().take(index + 1) {
3412-
self.require_type_is_sized(
3413-
ty,
3414-
expr.span,
3415-
ObligationCauseCode::MiscObligation,
3416-
);
3404+
self.require_type_is_sized(ty, expr.span, ObligationCauseCode::Misc);
34173405
}
34183406
if let Some(&field_ty) = tys.get(index) {
34193407
field_indices.push((FIRST_VARIANT, index.into()));

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14131413
) {
14141414
self.add_required_obligations_with_code(span, def_id, args, |idx, span| {
14151415
if span.is_dummy() {
1416-
ObligationCauseCode::ExprItemObligation(def_id, hir_id, idx)
1416+
ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
14171417
} else {
1418-
ObligationCauseCode::ExprBindingObligation(def_id, span, hir_id, idx)
1418+
ObligationCauseCode::WhereInExpr(def_id, span, hir_id, idx)
14191419
}
14201420
})
14211421
}

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

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1414
&self,
1515
error: &mut traits::FulfillmentError<'tcx>,
1616
) -> bool {
17-
let (ObligationCauseCode::ExprItemObligation(def_id, hir_id, idx)
18-
| ObligationCauseCode::ExprBindingObligation(def_id, _, hir_id, idx)) =
17+
let (ObligationCauseCode::MiscItemInExpr(def_id, hir_id, idx)
18+
| ObligationCauseCode::WhereInExpr(def_id, _, hir_id, idx)) =
1919
*error.obligation.cause.code().peel_derives()
2020
else {
2121
return false;
@@ -167,7 +167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
167167
// the method's turbofish segments but still use `FunctionArgumentObligation`
168168
// elsewhere. Hopefully this doesn't break something.
169169
error.obligation.cause.map_code(|parent_code| {
170-
ObligationCauseCode::FunctionArgumentObligation {
170+
ObligationCauseCode::FunctionArg {
171171
arg_hir_id: receiver.hir_id,
172172
call_hir_id: hir_id,
173173
parent_code,
@@ -456,12 +456,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
456456
self.blame_specific_expr_if_possible(error, arg_expr)
457457
}
458458

459-
error.obligation.cause.map_code(|parent_code| {
460-
ObligationCauseCode::FunctionArgumentObligation {
461-
arg_hir_id: arg.hir_id,
462-
call_hir_id,
463-
parent_code,
464-
}
459+
error.obligation.cause.map_code(|parent_code| ObligationCauseCode::FunctionArg {
460+
arg_hir_id: arg.hir_id,
461+
call_hir_id,
462+
parent_code,
465463
});
466464
return true;
467465
} else if args_referencing_param.len() > 0 {
@@ -514,12 +512,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
514512
expr: &'tcx hir::Expr<'tcx>,
515513
) -> Result<&'tcx hir::Expr<'tcx>, &'tcx hir::Expr<'tcx>> {
516514
match obligation_cause_code {
517-
traits::ObligationCauseCode::ExprBindingObligation(_, _, _, _) => {
515+
traits::ObligationCauseCode::WhereInExpr(_, _, _, _) => {
518516
// This is the "root"; we assume that the `expr` is already pointing here.
519517
// Therefore, we return `Ok` so that this `expr` can be refined further.
520518
Ok(expr)
521519
}
522-
traits::ObligationCauseCode::ImplDerivedObligation(impl_derived) => self
520+
traits::ObligationCauseCode::ImplDerived(impl_derived) => self
523521
.blame_specific_expr_if_possible_for_derived_predicate_obligation(
524522
impl_derived,
525523
expr,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
206206
self.register_wf_obligation(
207207
fn_input_ty.into(),
208208
arg_expr.span,
209-
ObligationCauseCode::MiscObligation,
209+
ObligationCauseCode::Misc,
210210
);
211211
}
212212

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
154154
}
155155

156156
pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
157-
self.cause(span, ObligationCauseCode::MiscObligation)
157+
self.cause(span, ObligationCauseCode::Misc)
158158
}
159159

160160
pub fn sess(&self) -> &Session {

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
565565
for obligation in traits::predicates_for_generics(
566566
|idx, span| {
567567
let code = if span.is_dummy() {
568-
ObligationCauseCode::ExprItemObligation(def_id, self.call_expr.hir_id, idx)
568+
ObligationCauseCode::MiscItemInExpr(def_id, self.call_expr.hir_id, idx)
569569
} else {
570-
ObligationCauseCode::ExprBindingObligation(
571-
def_id,
572-
span,
573-
self.call_expr.hir_id,
574-
idx,
575-
)
570+
ObligationCauseCode::WhereInExpr(def_id, span, self.call_expr.hir_id, idx)
576571
};
577572
traits::ObligationCause::new(self.span, self.body_id, code)
578573
},

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1402,13 +1402,13 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14021402
ocx.register_obligations(traits::predicates_for_generics(
14031403
|idx, span| {
14041404
let code = if span.is_dummy() {
1405-
ObligationCauseCode::ExprItemObligation(
1405+
ObligationCauseCode::MiscItemInExpr(
14061406
impl_def_id,
14071407
self.scope_expr_id,
14081408
idx,
14091409
)
14101410
} else {
1411-
ObligationCauseCode::ExprBindingObligation(
1411+
ObligationCauseCode::WhereInExpr(
14121412
impl_def_id,
14131413
span,
14141414
self.scope_expr_id,

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
146146
return false;
147147
};
148148
let trait_ref = ty::TraitRef::new(self.tcx, into_iterator_trait, [ty]);
149-
let cause = ObligationCause::new(span, self.body_id, ObligationCauseCode::MiscObligation);
149+
let cause = ObligationCause::new(span, self.body_id, ObligationCauseCode::Misc);
150150
let obligation = Obligation::new(self.tcx, cause, self.param_env, trait_ref);
151151
if !self.predicate_must_hold_modulo_regions(&obligation) {
152152
return false;
@@ -826,12 +826,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
826826
// Extract the predicate span and parent def id of the cause,
827827
// if we have one.
828828
let (item_def_id, cause_span) = match cause.as_ref().map(|cause| cause.code()) {
829-
Some(ObligationCauseCode::ImplDerivedObligation(data)) => {
829+
Some(ObligationCauseCode::ImplDerived(data)) => {
830830
(data.impl_or_alias_def_id, data.span)
831831
}
832832
Some(
833-
ObligationCauseCode::ExprBindingObligation(def_id, span, _, _)
834-
| ObligationCauseCode::BindingObligation(def_id, span),
833+
ObligationCauseCode::WhereInExpr(def_id, span, _, _)
834+
| ObligationCauseCode::Where(def_id, span),
835835
) => (*def_id, *span),
836836
_ => continue,
837837
};

0 commit comments

Comments
 (0)