Skip to content

Commit 6f77bfe

Browse files
Name tweaks
1 parent 9108294 commit 6f77bfe

File tree

22 files changed

+87
-75
lines changed

22 files changed

+87
-75
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,10 @@ 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::SpannedItem(CRATE_DEF_ID.to_def_id(), predicate_span))
2062+
Some(ObligationCauseCode::SpannedWhereClause(
2063+
CRATE_DEF_ID.to_def_id(),
2064+
predicate_span,
2065+
))
20632066
} else {
20642067
None
20652068
}

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::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(

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

+5-4
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::SpannedItem(proj.def_id, pred_span),
822+
ObligationCauseCode::SpannedWhereClause(proj.def_id, pred_span),
823823
),
824824
self.param_env,
825825
pred,
@@ -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::MiscItem(trait_ty.def_id)
2015+
ObligationCauseCode::WhereClause(trait_ty.def_id)
20162016
} else {
2017-
ObligationCauseCode::SpannedItem(trait_ty.def_id, span)
2017+
ObligationCauseCode::SpannedWhereClause(trait_ty.def_id, span)
20182018
};
20192019
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
20202020
};
@@ -2251,7 +2251,8 @@ fn try_report_async_mismatch<'tcx>(
22512251
};
22522252

22532253
for error in errors {
2254-
if let ObligationCauseCode::SpannedItem(def_id, _) = *error.root_obligation.cause.code()
2254+
if let ObligationCauseCode::SpannedWhereClause(def_id, _) =
2255+
*error.root_obligation.cause.code()
22552256
&& def_id == async_future_def_id
22562257
&& let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred()
22572258
&& let Some(proj) = proj.no_bound_vars()

Diff for: 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
});

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

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::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
}

Diff for: 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)

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

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

Diff for: 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
},

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::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,

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::SpannedItemInExpr(def_id, span, _, _)
834-
| ObligationCauseCode::SpannedItem(def_id, span),
833+
ObligationCauseCode::SpannedWhereClauseInExpr(def_id, span, _, _)
834+
| ObligationCauseCode::SpannedWhereClause(def_id, span),
835835
) => (*def_id, *span),
836836
_ => continue,
837837
};

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
883883
err.help("...or use `match` instead of `let...else`");
884884
}
885885
_ => {
886-
if let ObligationCauseCode::SpannedItem(_, span)
887-
| ObligationCauseCode::SpannedItemInExpr(_, span, ..) =
886+
if let ObligationCauseCode::SpannedWhereClause(_, span)
887+
| ObligationCauseCode::SpannedWhereClauseInExpr(_, span, ..) =
888888
cause.code().peel_derives()
889889
&& let TypeError::RegionsPlaceholderMismatch = terr
890890
{

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::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
};

Diff for: 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,

Diff for: 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
{

Diff for: 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
}

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

Diff for: 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>),

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

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

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

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

14011402
if let ObligationCauseCode::ImplDerived(cause) = &*code {
14021403
try_borrowing(cause.derived.parent_trait_pred, &[])
1403-
} else if let ObligationCauseCode::SpannedItem(_, _)
1404-
| ObligationCauseCode::MiscItem(_)
1405-
| ObligationCauseCode::MiscItemInExpr(..)
1406-
| ObligationCauseCode::SpannedItemInExpr(..) = code
1404+
} else if let ObligationCauseCode::SpannedWhereClause(_, _)
1405+
| ObligationCauseCode::WhereClause(_)
1406+
| ObligationCauseCode::WhereClauseInExpr(..)
1407+
| ObligationCauseCode::SpannedWhereClauseInExpr(..) = code
14071408
{
14081409
try_borrowing(poly_trait_pred, &never_suggest_borrow)
14091410
} else {
@@ -2099,10 +2100,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20992100
cause: &ObligationCauseCode<'tcx>,
21002101
err: &mut Diag<'tcx>,
21012102
) {
2102-
// First, look for an `SpannedItemInExpr`, which means we can get
2103+
// First, look for an `SpannedWhereClauseInExpr`, which means we can get
21032104
// the uninstantiated predicate list of the called function. And check
21042105
// that the predicate that we failed to satisfy is a `Fn`-like trait.
2105-
if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = cause
2106+
if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = cause
21062107
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
21072108
&& let Some(pred) = predicates.predicates.get(*idx)
21082109
&& let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder()
@@ -2743,12 +2744,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
27432744
ObligationCauseCode::TupleElem => {
27442745
err.note("only the last element of a tuple may have a dynamically sized type");
27452746
}
2746-
ObligationCauseCode::MiscItem(_) | ObligationCauseCode::MiscItemInExpr(..) => {
2747+
ObligationCauseCode::WhereClause(_) | ObligationCauseCode::WhereClauseInExpr(..) => {
27472748
// We hold the `DefId` of the item introducing the obligation, but displaying it
27482749
// doesn't add user usable information. It always point at an associated item.
27492750
}
2750-
ObligationCauseCode::SpannedItem(item_def_id, span)
2751-
| ObligationCauseCode::SpannedItemInExpr(item_def_id, span, ..) => {
2751+
ObligationCauseCode::SpannedWhereClause(item_def_id, span)
2752+
| ObligationCauseCode::SpannedWhereClauseInExpr(item_def_id, span, ..) => {
27522753
let item_name = tcx.def_path_str(item_def_id);
27532754
let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id));
27542755
let mut multispan = MultiSpan::from(span);
@@ -3799,7 +3800,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
37993800
// to an associated type (as seen from `trait_pred`) in the predicate. Like in
38003801
// trait_pred `S: Sum<<Self as Iterator>::Item>` and predicate `i32: Sum<&()>`
38013802
let mut type_diffs = vec![];
3802-
if let ObligationCauseCode::SpannedItemInExpr(def_id, _, _, idx) = parent_code
3803+
if let ObligationCauseCode::SpannedWhereClauseInExpr(def_id, _, _, idx) = parent_code
38033804
&& let Some(node_args) = typeck_results.node_args_opt(call_hir_id)
38043805
&& let where_clauses =
38053806
self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args)

0 commit comments

Comments
 (0)