Skip to content

Commit 7f54b9e

Browse files
Remove ObligationCause::span() method
1 parent 2507e83 commit 7f54b9e

File tree

9 files changed

+21
-26
lines changed

9 files changed

+21
-26
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
611611
Err(terr) => {
612612
let mut diag = struct_span_code_err!(
613613
tcx.dcx(),
614-
cause.span(),
614+
cause.span,
615615
E0053,
616616
"method `{}` has an incompatible return type for trait",
617617
trait_m.name
@@ -1169,7 +1169,7 @@ fn extract_spans_for_error_reporting<'tcx>(
11691169
TypeError::ArgumentMutability(i) | TypeError::ArgumentSorts(ExpectedFound { .. }, i) => {
11701170
(impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i)))
11711171
}
1172-
_ => (cause.span(), tcx.hir().span_if_local(trait_m.def_id)),
1172+
_ => (cause.span, tcx.hir().span_if_local(trait_m.def_id)),
11731173
}
11741174
}
11751175

compiler/rustc_hir_analysis/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub fn check_function_signature<'tcx>(
612612
match err {
613613
TypeError::ArgumentMutability(i)
614614
| TypeError::ArgumentSorts(ExpectedFound { .. }, i) => args.nth(i).unwrap(),
615-
_ => cause.span(),
615+
_ => cause.span,
616616
}
617617
}
618618

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20272027
}
20282028
Err(_) => {
20292029
span_bug!(
2030-
cause.span(),
2030+
cause.span,
20312031
"subtyping remaining fields of type changing FRU failed: {target_ty} != {fru_ty}: {}::{}",
20322032
variant.name,
20332033
ident.name,

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
550550
// This has/will have errored in wfcheck, which we cannot depend on from here, as typeck on functions
551551
// may run before wfcheck if the function is used in const eval.
552552
self.dcx().span_delayed_bug(
553-
cause.span(),
553+
cause.span,
554554
format!("{self_ty} was a subtype of {method_self_ty} but now is not?"),
555555
);
556556
}

compiler/rustc_middle/src/traits/mod.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ impl<'tcx> ObligationCause<'tcx> {
9292
ObligationCause { span, body_id: CRATE_DEF_ID, code: Default::default() }
9393
}
9494

95-
pub fn span(&self) -> Span {
96-
match *self.code() {
97-
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
98-
arm_span,
99-
..
100-
}) => arm_span,
101-
_ => self.span,
102-
}
103-
}
104-
10595
#[inline]
10696
pub fn code(&self) -> &ObligationCauseCode<'tcx> {
10797
&self.code
@@ -517,12 +507,17 @@ pub struct MatchExpressionArmCause<'tcx> {
517507
pub prior_arm_block_id: Option<HirId>,
518508
pub prior_arm_ty: Ty<'tcx>,
519509
pub prior_arm_span: Span,
510+
/// Span of the scrutinee of the match (the matched value).
520511
pub scrut_span: Span,
512+
/// Source of the match, i.e. `match` or a desugaring.
521513
pub source: hir::MatchSource,
522-
// Span of the *whole* match expr
514+
/// Span of the *whole* match expr.
523515
pub expr_span: Span,
516+
/// Spans of the previous arms except for those that diverge (i.e. evaluate to `!`).
517+
///
518+
/// These are used for pointing out errors that may affect several arms.
524519
pub prior_non_diverging_arms: Vec<Span>,
525-
// Is the expectation of this match expression an RPIT?
520+
/// Is the expectation of this match expression an RPIT?
526521
pub tail_defines_return_position_impl_trait: Option<LocalDefId>,
527522
}
528523

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
392392
Some(ty) if expected == ty => {
393393
let source_map = self.tcx.sess.source_map();
394394
err.span_suggestion(
395-
source_map.end_point(cause.span()),
395+
source_map.end_point(cause.span),
396396
"try removing this `?`",
397397
"",
398398
Applicability::MachineApplicable,
@@ -431,7 +431,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
431431
Some(ty) if expected == ty => {
432432
let source_map = self.tcx.sess.source_map();
433433
err.span_suggestion(
434-
source_map.end_point(cause.span()),
434+
source_map.end_point(cause.span),
435435
"try removing this `?`",
436436
"",
437437
Applicability::MachineApplicable,
@@ -1149,7 +1149,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11491149
terr: TypeError<'tcx>,
11501150
prefer_label: bool,
11511151
) {
1152-
let span = cause.span();
1152+
let span = cause.span;
11531153

11541154
// For some types of errors, expected-found does not make
11551155
// sense, so just ignore the values we were given.
@@ -1643,7 +1643,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
16431643
terr: TypeError<'tcx>,
16441644
) -> Vec<TypeErrorAdditionalDiags> {
16451645
let mut suggestions = Vec::new();
1646-
let span = trace.cause.span();
1646+
let span = trace.cause.span;
16471647
let values = self.resolve_vars_if_possible(trace.values);
16481648
if let Some((expected, found)) = values.ty() {
16491649
match (expected.kind(), found.kind()) {
@@ -1793,7 +1793,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17931793
) -> Diag<'a> {
17941794
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
17951795

1796-
let span = trace.cause.span();
1796+
let span = trace.cause.span;
17971797
let failure_code = trace.cause.as_failure_code_diag(
17981798
terr,
17991799
span,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
237237
expected_args: GenericArgsRef<'tcx>,
238238
actual_args: GenericArgsRef<'tcx>,
239239
) -> Diag<'tcx> {
240-
let span = cause.span();
240+
let span = cause.span;
241241

242242
let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) =
243243
if let ObligationCauseCode::WhereClause(def_id, span)

compiler/rustc_trait_selection/src/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
11801180
selcx.tcx(),
11811181
selcx.tcx().require_lang_item(
11821182
LangItem::Sized,
1183-
Some(obligation.cause.span()),
1183+
Some(obligation.cause.span),
11841184
),
11851185
[self_ty],
11861186
),
@@ -1600,7 +1600,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
16001600
// exist. Instead, `Pointee<Metadata = ()>` should be a supertrait of `Sized`.
16011601
let sized_predicate = ty::TraitRef::new(
16021602
tcx,
1603-
tcx.require_lang_item(LangItem::Sized, Some(obligation.cause.span())),
1603+
tcx.require_lang_item(LangItem::Sized, Some(obligation.cause.span)),
16041604
[self_ty],
16051605
);
16061606
obligations.push(obligation.with(tcx, sized_predicate));

compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'tcx> InferCtxt<'tcx> {
9090
assert!(!self.intercrate);
9191
let c_pred =
9292
self.canonicalize_query(param_env.and(obligation.predicate), &mut _orig_values);
93-
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
93+
self.tcx.at(obligation.cause.span).evaluate_obligation(c_pred)
9494
}
9595
}
9696

0 commit comments

Comments
 (0)