Skip to content

Commit 05afef2

Browse files
Name tweaks
1 parent d18053d commit 05afef2

File tree

22 files changed

+87
-75
lines changed

22 files changed

+87
-75
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20532053
// We currently do not store the `DefId` in the `ConstraintCategory`
20542054
// for performances reasons. The error reporting code used by NLL only
20552055
// uses the span, so this doesn't cause any problems at the moment.
2056-
Some(ObligationCauseCode::SpannedItem(CRATE_DEF_ID.to_def_id(), predicate_span))
2056+
Some(ObligationCauseCode::SpannedWhereClause(
2057+
CRATE_DEF_ID.to_def_id(),
2058+
predicate_span,
2059+
))
20572060
} else {
20582061
None
20592062
}

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::MiscItem(callee),
741+
ObligationCauseCode::WhereClause(callee),
742742
);
743743
let normalized_predicates = ocx.normalize(&cause, param_env, predicates);
744744
ocx.register_obligations(traits::predicates_for_generics(

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
823823
ObligationCause::new(
824824
self.span,
825825
self.body_id,
826-
ObligationCauseCode::SpannedItem(proj.def_id, pred_span),
826+
ObligationCauseCode::SpannedWhereClause(proj.def_id, pred_span),
827827
),
828828
self.param_env,
829829
pred,
@@ -2014,9 +2014,9 @@ pub(super) fn check_type_bounds<'tcx>(
20142014
);
20152015
let mk_cause = |span: Span| {
20162016
let code = if span.is_dummy() {
2017-
ObligationCauseCode::MiscItem(trait_ty.def_id)
2017+
ObligationCauseCode::WhereClause(trait_ty.def_id)
20182018
} else {
2019-
ObligationCauseCode::SpannedItem(trait_ty.def_id, span)
2019+
ObligationCauseCode::SpannedWhereClause(trait_ty.def_id, span)
20202020
};
20212021
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
20222022
};
@@ -2253,7 +2253,8 @@ fn try_report_async_mismatch<'tcx>(
22532253
};
22542254

22552255
for error in errors {
2256-
if let ObligationCauseCode::SpannedItem(def_id, _) = *error.root_obligation.cause.code()
2256+
if let ObligationCauseCode::SpannedWhereClause(def_id, _) =
2257+
*error.root_obligation.cause.code()
22572258
&& def_id == async_future_def_id
22582259
&& let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred()
22592260
&& let Some(proj) = proj.no_bound_vars()

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -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::MiscItem(def_id.to_def_id()),
1553+
ObligationCauseCode::WhereClause(def_id.to_def_id()),
15541554
);
15551555
traits::Obligation::new(tcx, cause, wfcx.param_env, pred)
15561556
});

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

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::MiscItemInExpr(def_id, hir_id, idx)
1416+
ObligationCauseCode::WhereClauseInExpr(def_id, hir_id, idx)
14171417
} else {
1418-
ObligationCauseCode::SpannedItemInExpr(def_id, span, hir_id, idx)
1418+
ObligationCauseCode::SpannedWhereClauseInExpr(def_id, span, hir_id, idx)
14191419
}
14201420
})
14211421
}

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+3-3
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::MiscItemInExpr(def_id, hir_id, idx)
18-
| ObligationCauseCode::SpannedItemInExpr(def_id, _, hir_id, idx)) =
17+
let (ObligationCauseCode::WhereClauseInExpr(def_id, hir_id, idx)
18+
| ObligationCauseCode::SpannedWhereClauseInExpr(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::SpannedItemInExpr(_, _, _, _) => {
515+
traits::ObligationCauseCode::SpannedWhereClauseInExpr(_, _, _, _) => {
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)

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20142014
for (span, code) in errors_causecode {
20152015
self.dcx().try_steal_modify_and_emit_err(span, StashKey::MaybeForgetReturn, |err| {
20162016
if let Some(fn_sig) = self.body_fn_sig()
2017-
&& let ObligationCauseCode::SpannedItemInExpr(_, _, binding_hir_id, ..) = code
2017+
&& let ObligationCauseCode::SpannedWhereClauseInExpr(_, _, binding_hir_id, ..) =
2018+
code
20182019
&& !fn_sig.output().is_unit()
20192020
{
20202021
let mut block_num = 0;
@@ -2103,7 +2104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21032104
//
21042105
// This is because due to normalization, we often register duplicate
21052106
// obligations with misc obligations that are basically impossible to
2106-
// line back up with a useful SpannedItemInExpr.
2107+
// line back up with a useful SpannedWhereClauseInExpr.
21072108
for error in not_adjusted {
21082109
for (span, predicate, cause) in &remap_cause {
21092110
if *predicate == error.obligation.predicate

compiler/rustc_hir_typeck/src/method/confirm.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,14 @@ 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::MiscItemInExpr(def_id, self.call_expr.hir_id, idx)
568+
ObligationCauseCode::WhereClauseInExpr(def_id, self.call_expr.hir_id, idx)
569569
} else {
570-
ObligationCauseCode::SpannedItemInExpr(def_id, span, self.call_expr.hir_id, idx)
570+
ObligationCauseCode::SpannedWhereClauseInExpr(
571+
def_id,
572+
span,
573+
self.call_expr.hir_id,
574+
idx,
575+
)
571576
};
572577
traits::ObligationCause::new(self.span, self.body_id, code)
573578
},

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::MiscItemInExpr(
1405+
ObligationCauseCode::WhereClauseInExpr(
14061406
impl_def_id,
14071407
self.scope_expr_id,
14081408
idx,
14091409
)
14101410
} else {
1411-
ObligationCauseCode::SpannedItemInExpr(
1411+
ObligationCauseCode::SpannedWhereClauseInExpr(
14121412
impl_def_id,
14131413
span,
14141414
self.scope_expr_id,

compiler/rustc_hir_typeck/src/method/suggest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
834834
(data.impl_or_alias_def_id, data.span)
835835
}
836836
Some(
837-
ObligationCauseCode::SpannedItemInExpr(def_id, span, _, _)
838-
| ObligationCauseCode::SpannedItem(def_id, span),
837+
ObligationCauseCode::SpannedWhereClauseInExpr(def_id, span, _, _)
838+
| ObligationCauseCode::SpannedWhereClause(def_id, span),
839839
) => (*def_id, *span),
840840
_ => continue,
841841
};

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
885885
err.help("...or use `match` instead of `let...else`");
886886
}
887887
_ => {
888-
if let ObligationCauseCode::SpannedItem(_, span)
889-
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
888+
if let ObligationCauseCode::SpannedWhereClause(_, span)
889+
| ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) =
890890
cause.code().peel_derives()
891891
&& let TypeError::RegionsPlaceholderMismatch = terr
892892
{

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::SpannedItem(_, binding_span)
42-
| ObligationCauseCode::SpannedItemInExpr(_, binding_span, ..)) = *parent.code()
41+
let (ObligationCauseCode::SpannedWhereClause(_, binding_span)
42+
| ObligationCauseCode::SpannedWhereClauseInExpr(_, binding_span, ..)) = *parent.code()
4343
else {
4444
return None;
4545
};

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
240240
let span = cause.span();
241241

242242
let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) =
243-
if let ObligationCauseCode::MiscItem(def_id)
244-
| ObligationCauseCode::MiscItemInExpr(def_id, ..) = *cause.code()
243+
if let ObligationCauseCode::WhereClause(def_id)
244+
| ObligationCauseCode::WhereClauseInExpr(def_id, ..) = *cause.code()
245245
{
246246
(
247247
true,

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
214214
_ => cause.code(),
215215
}
216216
&& let (
217-
&ObligationCauseCode::MiscItem(item_def_id)
218-
| &ObligationCauseCode::MiscItemInExpr(item_def_id, ..),
217+
&ObligationCauseCode::WhereClause(item_def_id)
218+
| &ObligationCauseCode::WhereClauseInExpr(item_def_id, ..),
219219
None,
220220
) = (code, override_error_code)
221221
{

compiler/rustc_infer/src/infer/error_reporting/note.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -357,21 +357,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
357357
infer::Subtype(box ref trace)
358358
if matches!(
359359
&trace.cause.code().peel_derives(),
360-
ObligationCauseCode::SpannedItem(..)
361-
| ObligationCauseCode::SpannedItemInExpr(..)
360+
ObligationCauseCode::SpannedWhereClause(..)
361+
| ObligationCauseCode::SpannedWhereClauseInExpr(..)
362362
) =>
363363
{
364364
// Hack to get around the borrow checker because trace.cause has an `Rc`.
365-
if let ObligationCauseCode::SpannedItem(_, span)
366-
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
365+
if let ObligationCauseCode::SpannedWhereClause(_, span)
366+
| ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) =
367367
&trace.cause.code().peel_derives()
368368
{
369369
let span = *span;
370370
self.report_concrete_failure(placeholder_origin, sub, sup)
371371
.with_span_note(span, "the lifetime requirement is introduced here")
372372
} else {
373373
unreachable!(
374-
"control flow ensures we have a `BindingObligation` or `SpannedItemInExpr` here..."
374+
"control flow ensures we have a `BindingObligation` or `SpannedWhereClauseInExpr` here..."
375375
)
376376
}
377377
}

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::SpannedItem(_, span)
107-
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) => Some(*span),
106+
ObligationCauseCode::SpannedWhereClause(_, span)
107+
| ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) => Some(*span),
108108
_ => None,
109109
},
110110
)

compiler/rustc_middle/src/traits/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,20 @@ pub enum ObligationCauseCode<'tcx> {
249249

250250
/// Must satisfy all of the where-clause predicates of the
251251
/// given item.
252-
MiscItem(DefId),
252+
WhereClause(DefId),
253253

254-
/// Like `MiscItem`, but carries the span of the
254+
/// Like `WhereClause`, but carries the span of the
255255
/// predicate when it can be identified.
256-
SpannedItem(DefId, Span),
256+
SpannedWhereClause(DefId, Span),
257257

258-
/// Like `MiscItem`, but carries the `HirId` of the
258+
/// Like `WhereClause`, but carries the `HirId` of the
259259
/// expression that caused the obligation, and the `usize`
260260
/// indicates exactly which predicate it is in the list of
261261
/// instantiated predicates.
262-
MiscItemInExpr(DefId, HirId, usize),
262+
WhereClauseInExpr(DefId, HirId, usize),
263263

264-
/// Combines `SpannedItem` and `MiscItemInExpr`.
265-
SpannedItemInExpr(DefId, Span, HirId, usize),
264+
/// Combines `SpannedWhereClause` and `WhereClauseInExpr`.
265+
SpannedWhereClauseInExpr(DefId, Span, HirId, usize),
266266

267267
/// A type like `&'a T` is WF only if `T: 'a`.
268268
ReferenceOutlivesReferent(Ty<'tcx>),

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12041204

12051205
let code = match obligation.cause.code() {
12061206
ObligationCauseCode::FunctionArg { parent_code, .. } => parent_code,
1207-
c @ ObligationCauseCode::MiscItem(_) | c @ ObligationCauseCode::MiscItemInExpr(..) => c,
1207+
c @ ObligationCauseCode::WhereClause(_)
1208+
| c @ ObligationCauseCode::WhereClauseInExpr(..) => c,
12081209
c if matches!(
12091210
span.ctxt().outer_expn_data().kind,
12101211
ExpnKind::Desugaring(DesugaringKind::ForLoop)
@@ -1260,8 +1261,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12601261
let mut_ref_self_ty_satisfies_pred = mk_result(trait_pred_and_mut_ref);
12611262

12621263
let (ref_inner_ty_satisfies_pred, ref_inner_ty_mut) =
1263-
if let ObligationCauseCode::MiscItem(_) | ObligationCauseCode::MiscItemInExpr(..) =
1264-
obligation.cause.code()
1264+
if let ObligationCauseCode::WhereClause(_)
1265+
| ObligationCauseCode::WhereClauseInExpr(..) = obligation.cause.code()
12651266
&& let ty::Ref(_, ty, mutability) = old_pred.self_ty().skip_binder().kind()
12661267
{
12671268
(
@@ -1401,10 +1402,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14011402

14021403
if let ObligationCauseCode::ImplDerived(cause) = &*code {
14031404
try_borrowing(cause.derived.parent_trait_pred, &[])
1404-
} else if let ObligationCauseCode::SpannedItem(_, _)
1405-
| ObligationCauseCode::MiscItem(_)
1406-
| ObligationCauseCode::MiscItemInExpr(..)
1407-
| ObligationCauseCode::SpannedItemInExpr(..) = code
1405+
} else if let ObligationCauseCode::SpannedWhereClause(_, _)
1406+
| ObligationCauseCode::WhereClause(_)
1407+
| ObligationCauseCode::WhereClauseInExpr(..)
1408+
| ObligationCauseCode::SpannedWhereClauseInExpr(..) = code
14081409
{
14091410
try_borrowing(poly_trait_pred, &never_suggest_borrow)
14101411
} else {
@@ -2101,10 +2102,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
21012102
cause: &ObligationCauseCode<'tcx>,
21022103
err: &mut Diag<'tcx>,
21032104
) {
2104-
// First, look for an `SpannedItemInExpr`, which means we can get
2105+
// First, look for an `SpannedWhereClauseInExpr`, which means we can get
21052106
// the uninstantiated predicate list of the called function. And check
21062107
// that the predicate that we failed to satisfy is a `Fn`-like trait.
2107-
if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = cause
2108+
if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = cause
21082109
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
21092110
&& let Some(pred) = predicates.predicates.get(*idx)
21102111
&& let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder()
@@ -2745,12 +2746,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
27452746
ObligationCauseCode::TupleElem => {
27462747
err.note("only the last element of a tuple may have a dynamically sized type");
27472748
}
2748-
ObligationCauseCode::MiscItem(_) | ObligationCauseCode::MiscItemInExpr(..) => {
2749+
ObligationCauseCode::WhereClause(_) | ObligationCauseCode::WhereClauseInExpr(..) => {
27492750
// We hold the `DefId` of the item introducing the obligation, but displaying it
27502751
// doesn't add user usable information. It always point at an associated item.
27512752
}
2752-
ObligationCauseCode::SpannedItem(item_def_id, span)
2753-
| ObligationCauseCode::SpannedItemInExpr(item_def_id, span, ..) => {
2753+
ObligationCauseCode::SpannedWhereClause(item_def_id, span)
2754+
| ObligationCauseCode::SpannedWhereClauseInExpr(item_def_id, span, ..) => {
27542755
let item_name = tcx.def_path_str(item_def_id);
27552756
let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id));
27562757
let mut multispan = MultiSpan::from(span);
@@ -3801,7 +3802,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
38013802
// to an associated type (as seen from `trait_pred`) in the predicate. Like in
38023803
// trait_pred `S: Sum<<Self as Iterator>::Item>` and predicate `i32: Sum<&()>`
38033804
let mut type_diffs = vec![];
3804-
if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = parent_code
3805+
if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = parent_code
38053806
&& let Some(node_args) = typeck_results.node_args_opt(call_hir_id)
38063807
&& let where_clauses =
38073808
self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args)

0 commit comments

Comments
 (0)