Skip to content

Commit 1d93b35

Browse files
committed
Remove overloaded_span argument from new, where it is usually redundant with the main span
1 parent a7a40dd commit 1d93b35

File tree

6 files changed

+11
-22
lines changed

6 files changed

+11
-22
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,7 @@ fn receiver_is_valid<'tcx>(
17081708
return true;
17091709
}
17101710

1711-
let mut autoderef =
1712-
Autoderef::new(infcx, wfcx.param_env, wfcx.body_id, span, receiver_ty, span);
1711+
let mut autoderef = Autoderef::new(infcx, wfcx.param_env, wfcx.body_id, span, receiver_ty);
17131712

17141713
// The `arbitrary_self_types` feature allows raw pointer receivers like `self: *const Self`.
17151714
if arbitrary_self_types_enabled {

compiler/rustc_hir_typeck/src/autoderef.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,7 @@ use std::iter;
1212

1313
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1414
pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> {
15-
self.autoderef_overloaded_span(span, base_ty, span)
16-
}
17-
18-
/// Like `autoderef`, but provides a custom `Span` to use for calls to
19-
/// an overloaded `Deref` operator
20-
pub fn autoderef_overloaded_span(
21-
&'a self,
22-
span: Span,
23-
base_ty: Ty<'tcx>,
24-
overloaded_span: Span,
25-
) -> Autoderef<'a, 'tcx> {
26-
Autoderef::new(self, self.param_env, self.body_id, span, base_ty, overloaded_span)
15+
Autoderef::new(self, self.param_env, self.body_id, span, base_ty)
2716
}
2817

2918
pub fn try_overloaded_deref(

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
152152
// Commit the autoderefs by calling `autoderef` again, but this
153153
// time writing the results into the various typeck results.
154154
let mut autoderef =
155-
self.autoderef_overloaded_span(self.span, unadjusted_self_ty, self.call_expr.span);
155+
self.autoderef(self.span, unadjusted_self_ty).with_overloaded_span(self.call_expr.span);
156156
let Some((ty, n)) = autoderef.nth(pick.autoderefs) else {
157157
return self.tcx.ty_error_with_message(
158158
rustc_span::DUMMY_SP,

compiler/rustc_hir_typeck/src/method/probe.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,9 @@ fn method_autoderef_steps<'tcx>(
475475
let (ref infcx, goal, inference_vars) = tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &goal);
476476
let ParamEnvAnd { param_env, value: self_ty } = goal;
477477

478-
let mut autoderef =
479-
Autoderef::new(infcx, param_env, hir::CRATE_HIR_ID, DUMMY_SP, self_ty, DUMMY_SP)
480-
.include_raw_pointers()
481-
.silence_errors();
478+
let mut autoderef = Autoderef::new(infcx, param_env, hir::CRATE_HIR_ID, DUMMY_SP, self_ty)
479+
.include_raw_pointers()
480+
.silence_errors();
482481
let mut reached_raw_pointer = false;
483482
let mut steps: Vec<_> = autoderef
484483
.by_ref()

compiler/rustc_trait_selection/src/autoderef.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
9999
body_id: hir::HirId,
100100
span: Span,
101101
base_ty: Ty<'tcx>,
102-
overloaded_span: Span,
103102
) -> Autoderef<'a, 'tcx> {
104103
Autoderef {
105104
infcx,
106105
span,
107-
overloaded_span,
106+
overloaded_span: span,
108107
body_id,
109108
param_env,
110109
state: AutoderefSnapshot {
@@ -119,6 +118,10 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
119118
}
120119
}
121120

121+
pub fn with_overloaded_span(self, overloaded_span: Span) -> Self {
122+
Self { overloaded_span, ..self }
123+
}
124+
122125
fn overloaded_deref_ty(&mut self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
123126
debug!("overloaded_deref_ty({:?})", ty);
124127

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

-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
714714
obligation.cause.body_id,
715715
span,
716716
base_ty,
717-
span,
718717
);
719718
if let Some(steps) = autoderef.find_map(|(ty, steps)| {
720719
// Re-add the `&`

0 commit comments

Comments
 (0)