Skip to content

Commit c3c3719

Browse files
committed
Remove some redundant span arguments
1 parent 44c4a7b commit c3c3719

File tree

4 files changed

+32
-57
lines changed

4 files changed

+32
-57
lines changed

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
504504
// method lookup.
505505
let Ok(pick) = self
506506
.probe_for_name(
507-
call_expr.span,
508507
Mode::MethodCall,
509508
segment.ident,
510509
IsSuggestion(true),

compiler/rustc_hir_typeck/src/method/mod.rs

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9494
allow_private: bool,
9595
) -> bool {
9696
match self.probe_for_name(
97-
method_name.span,
9897
probe::Mode::MethodCall,
9998
method_name,
10099
IsSuggestion(false),
@@ -124,7 +123,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
124123
) {
125124
let params = self
126125
.probe_for_name(
127-
method_name.span,
128126
probe::Mode::MethodCall,
129127
method_name,
130128
IsSuggestion(true),
@@ -174,7 +172,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
174172
args: &'tcx [hir::Expr<'tcx>],
175173
) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
176174
let pick =
177-
self.lookup_probe(span, segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;
175+
self.lookup_probe(segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;
178176

179177
self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick, args);
180178

@@ -199,7 +197,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
199197
.mk_ref(*region, ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() });
200198
// We probe again to see if there might be a borrow mutability discrepancy.
201199
match self.lookup_probe(
202-
span,
203200
segment.ident,
204201
trait_type,
205202
call_expr,
@@ -213,28 +210,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
213210
}
214211

215212
// We probe again, taking all traits into account (not only those in scope).
216-
let mut candidates = match self.lookup_probe(
217-
span,
218-
segment.ident,
219-
self_ty,
220-
call_expr,
221-
ProbeScope::AllTraits,
222-
) {
223-
// If we find a different result the caller probably forgot to import a trait.
224-
Ok(ref new_pick) if *new_pick != pick => vec![new_pick.item.container_id(self.tcx)],
225-
Err(Ambiguity(ref sources)) => sources
226-
.iter()
227-
.filter_map(|source| {
228-
match *source {
229-
// Note: this cannot come from an inherent impl,
230-
// because the first probing succeeded.
231-
CandidateSource::Impl(def) => self.tcx.trait_id_of_impl(def),
232-
CandidateSource::Trait(_) => None,
233-
}
234-
})
235-
.collect(),
236-
_ => Vec::new(),
237-
};
213+
let mut candidates =
214+
match self.lookup_probe(segment.ident, self_ty, call_expr, ProbeScope::AllTraits) {
215+
// If we find a different result the caller probably forgot to import a trait.
216+
Ok(ref new_pick) if *new_pick != pick => {
217+
vec![new_pick.item.container_id(self.tcx)]
218+
}
219+
Err(Ambiguity(ref sources)) => sources
220+
.iter()
221+
.filter_map(|source| {
222+
match *source {
223+
// Note: this cannot come from an inherent impl,
224+
// because the first probing succeeded.
225+
CandidateSource::Impl(def) => self.tcx.trait_id_of_impl(def),
226+
CandidateSource::Trait(_) => None,
227+
}
228+
})
229+
.collect(),
230+
_ => Vec::new(),
231+
};
238232
candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id));
239233

240234
return Err(IllegalSizedBound(candidates, needs_mut, span));
@@ -246,14 +240,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
246240
#[instrument(level = "debug", skip(self, call_expr))]
247241
pub fn lookup_probe(
248242
&self,
249-
span: Span,
250243
method_name: Ident,
251244
self_ty: Ty<'tcx>,
252245
call_expr: &'tcx hir::Expr<'tcx>,
253246
scope: ProbeScope,
254247
) -> probe::PickResult<'tcx> {
255248
self.probe_for_name(
256-
span,
257249
probe::Mode::MethodCall,
258250
method_name,
259251
IsSuggestion(false),
@@ -584,9 +576,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
584576
}
585577

586578
let pick = self.probe_for_name(
587-
span,
588579
probe::Mode::Path,
589-
method_name,
580+
method_name.with_span_pos(span),
590581
IsSuggestion(false),
591582
self_ty,
592583
expr_id,

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
298298
#[instrument(level = "debug", skip(self))]
299299
pub fn probe_for_name(
300300
&self,
301-
span: Span,
302301
mode: Mode,
303302
item_name: Ident,
304303
is_suggestion: IsSuggestion,
@@ -307,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
307306
scope: ProbeScope,
308307
) -> PickResult<'tcx> {
309308
self.probe_op(
310-
span,
309+
item_name.span,
311310
mode,
312311
Some(item_name),
313312
None,

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
376376
.hir()
377377
.expect_expr(self.tcx.hir().get_parent_node(rcvr_expr.hir_id));
378378
let probe = self.lookup_probe(
379-
span,
380379
item_name,
381380
output_ty,
382381
call_expr,
@@ -914,7 +913,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
914913
);
915914
}
916915

917-
self.check_for_inner_self(&mut err, source, span, rcvr_ty, item_name);
916+
self.check_for_inner_self(&mut err, source, rcvr_ty, item_name);
918917

919918
bound_spans.sort();
920919
bound_spans.dedup();
@@ -1321,7 +1320,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13211320
self.tcx.bound_type_of(range_def_id).subst(self.tcx, &[actual.into()]);
13221321

13231322
let pick = self.probe_for_name(
1324-
span,
13251323
Mode::MethodCall,
13261324
item_name,
13271325
IsSuggestion(true),
@@ -1500,7 +1498,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15001498
span,
15011499
&|_, field_ty| {
15021500
self.lookup_probe(
1503-
span,
15041501
item_name,
15051502
field_ty,
15061503
call_expr,
@@ -1548,7 +1545,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15481545
&self,
15491546
err: &mut Diagnostic,
15501547
source: SelfSource<'tcx>,
1551-
span: Span,
15521548
actual: Ty<'tcx>,
15531549
item_name: Ident,
15541550
) {
@@ -1571,15 +1567,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15711567
return None;
15721568
}
15731569

1574-
self.lookup_probe(
1575-
span,
1576-
item_name,
1577-
field_ty,
1578-
call_expr,
1579-
ProbeScope::TraitsInScope,
1580-
)
1581-
.ok()
1582-
.map(|pick| (variant, field, pick))
1570+
self.lookup_probe(item_name, field_ty, call_expr, ProbeScope::TraitsInScope)
1571+
.ok()
1572+
.map(|pick| (variant, field, pick))
15831573
})
15841574
.collect();
15851575

@@ -1644,12 +1634,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16441634
let [first] = ***substs else { return; };
16451635
let ty::GenericArgKind::Type(ty) = first.unpack() else { return; };
16461636
let Ok(pick) = self.lookup_probe(
1647-
span,
1648-
item_name,
1649-
ty,
1650-
call_expr,
1651-
ProbeScope::TraitsInScope,
1652-
) else { return; };
1637+
item_name,
1638+
ty,
1639+
call_expr,
1640+
ProbeScope::TraitsInScope,
1641+
) else { return; };
16531642

16541643
let name = self.ty_to_value_string(actual);
16551644
let inner_id = kind.did();
@@ -1899,7 +1888,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18991888
let SelfSource::QPath(ty) = self_source else { return; };
19001889
for (deref_ty, _) in self.autoderef(rustc_span::DUMMY_SP, rcvr_ty).skip(1) {
19011890
if let Ok(pick) = self.probe_for_name(
1902-
ty.span,
19031891
Mode::Path,
19041892
item_name,
19051893
IsSuggestion(true),
@@ -2107,7 +2095,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21072095
(self.tcx.mk_mut_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&mut "),
21082096
(self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&"),
21092097
] {
2110-
match self.lookup_probe(span, item_name, *rcvr_ty, rcvr, ProbeScope::AllTraits) {
2098+
match self.lookup_probe(item_name, *rcvr_ty, rcvr, ProbeScope::AllTraits) {
21112099
Ok(pick) => {
21122100
// If the method is defined for the receiver we have, it likely wasn't `use`d.
21132101
// We point at the method, but we just skip the rest of the check for arbitrary
@@ -2141,7 +2129,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21412129
] {
21422130
if let Some(new_rcvr_t) = *rcvr_ty
21432131
&& let Ok(pick) = self.lookup_probe(
2144-
span,
21452132
item_name,
21462133
new_rcvr_t,
21472134
rcvr,
@@ -2522,7 +2509,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25222509
span: method_name.span,
25232510
};
25242511
let probe = self.lookup_probe(
2525-
expr.span,
25262512
new_name,
25272513
self_ty,
25282514
self_expr,

0 commit comments

Comments
 (0)