Skip to content

Commit 78efaf4

Browse files
remove tcx from ObligationCauseCode::span
1 parent 27b6ab9 commit 78efaf4

File tree

10 files changed

+12
-18
lines changed

10 files changed

+12
-18
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
714714
}
715715

716716
fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {
717-
span_bug!(
718-
self.cause.span(self.infcx.tcx),
719-
"generic_const_exprs: unreachable `const_equate`"
720-
);
717+
span_bug!(self.cause.span(), "generic_const_exprs: unreachable `const_equate`");
721718
}
722719

723720
fn normalization() -> NormalizationStrategy {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14351435
swap_secondary_and_primary: bool,
14361436
force_label: bool,
14371437
) {
1438-
let span = cause.span(self.tcx);
1438+
let span = cause.span();
14391439

14401440
// For some types of errors, expected-found does not make
14411441
// sense, so just ignore the values we were given.
@@ -2085,7 +2085,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20852085

20862086
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
20872087

2088-
let span = trace.cause.span(self.tcx);
2088+
let span = trace.cause.span();
20892089
let failure_code = trace.cause.as_failure_code(terr);
20902090
let mut diag = match failure_code {
20912091
FailureCode::Error0038(did) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
204204
expected_substs: SubstsRef<'tcx>,
205205
actual_substs: SubstsRef<'tcx>,
206206
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
207-
let span = cause.span(self.tcx());
207+
let span = cause.span();
208208
let msg = format!(
209209
"implementation of `{}` is not general enough",
210210
self.tcx().def_path_str(trait_def_id),

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2727

2828
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
2929
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
30-
err.span_label(
31-
span,
32-
format!("definition of `{}` from trait", item_name),
33-
);
30+
err.span_label(span, format!("definition of `{}` from trait", item_name));
3431
}
3532

3633
err.span_label(error_span, format!("impl has extra requirement {}", requirement));

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'tcx> ObligationCause<'tcx> {
139139
ObligationCause { span, body_id: hir::CRATE_HIR_ID, code: Default::default() }
140140
}
141141

142-
pub fn span(&self, _tcx: TyCtxt<'tcx>) -> Span {
142+
pub fn span(&self) -> Span {
143143
match *self.code() {
144144
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
145145
arm_span,

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
603603
),
604604
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
605605
span_bug!(
606-
obligation.cause.span(self.selcx.tcx()),
606+
obligation.cause.span(),
607607
"ConstEquate: const_eval_resolve returned an unexpected error"
608608
)
609609
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
8484
// Run canonical query. If overflow occurs, rerun from scratch but this time
8585
// in standard trait query mode so that overflow is handled appropriately
8686
// within `SelectionContext`.
87-
self.tcx.at(obligation.cause.span(self.tcx)).evaluate_obligation(c_pred)
87+
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
8888
}
8989

9090
// Helper function that canonicalizes and runs the query. If an

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
742742
| (_, Err(ErrorHandled::Reported(_))) => Ok(EvaluatedToErr),
743743
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
744744
span_bug!(
745-
obligation.cause.span(self.tcx()),
745+
obligation.cause.span(),
746746
"ConstEquate: const_eval_resolve returned an unexpected error"
747747
)
748748
}

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn compare_predicate_entailment<'tcx>(
298298

299299
let mut diag = struct_span_err!(
300300
tcx.sess,
301-
cause.span(tcx),
301+
cause.span(),
302302
E0053,
303303
"method `{}` has an incompatible type for trait",
304304
trait_m.name
@@ -492,7 +492,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
492492
TypeError::ArgumentSorts(ExpectedFound { .. }, i) => {
493493
(impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i)))
494494
}
495-
_ => (cause.span(tcx), tcx.hir().span_if_local(trait_m.def_id)),
495+
_ => (cause.span(), tcx.hir().span_if_local(trait_m.def_id)),
496496
}
497497
}
498498

compiler/rustc_typeck/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, mut span: Span, id: hir::HirI
18381838
if let Some(hir::Generics { predicates, .. }) =
18391839
hir_node.and_then(|node| node.generics())
18401840
{
1841-
let obligation_span = obligation.cause.span(fcx.tcx);
1841+
let obligation_span = obligation.cause.span();
18421842

18431843
span = predicates
18441844
.iter()

0 commit comments

Comments
 (0)