Skip to content

Commit 978ed96

Browse files
authored
Rollup merge of rust-lang#139232 - nnethercote:remove-Map-5, r=Zalathar
Move methods from `Map` to `TyCtxt`, part 5. This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR. A follow-up to rust-lang#137504. r? `@Zalathar`
2 parents 2e181e7 + 130af3f commit 978ed96

16 files changed

+22
-24
lines changed

clippy_lints/src/casts/unnecessary_cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub(super) fn check<'tcx>(
143143

144144
if cast_from.kind() == cast_to.kind() && !expr.span.in_external_macro(cx.sess().source_map()) {
145145
if let Some(id) = path_to_local(cast_expr)
146-
&& !cx.tcx.hir().span(id).eq_ctxt(cast_expr.span)
146+
&& !cx.tcx.hir_span(id).eq_ctxt(cast_expr.span)
147147
{
148148
// Binding context is different than the identifiers context.
149149
// Weird macro wizardry could be involved here.

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn check_hash_peq<'tcx>(
254254
|diag| {
255255
if let Some(local_def_id) = impl_id.as_local() {
256256
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
257-
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here");
257+
diag.span_note(cx.tcx.hir_span(hir_id), "`PartialEq` implemented here");
258258
}
259259
},
260260
);
@@ -298,7 +298,7 @@ fn check_ord_partial_ord<'tcx>(
298298
span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| {
299299
if let Some(local_def_id) = impl_id.as_local() {
300300
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
301-
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here");
301+
diag.span_note(cx.tcx.hir_span(hir_id), "`PartialOrd` implemented here");
302302
}
303303
});
304304
}

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
120120
cx,
121121
BOXED_LOCAL,
122122
node,
123-
cx.tcx.hir().span(node),
123+
cx.tcx.hir_span(node),
124124
"local variable doesn't need to be boxed here",
125125
);
126126
}

clippy_lints/src/index_refutable_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> {
248248
{
249249
use_info
250250
.index_use
251-
.push((index_value, cx.tcx.hir().span(parent_expr.hir_id)));
251+
.push((index_value, cx.tcx.hir_span(parent_expr.hir_id)));
252252
return;
253253
}
254254

clippy_lints/src/loops/mut_range_bound.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
8585
if bk == ty::BorrowKind::Mutable {
8686
if let PlaceBase::Local(id) = cmt.place.base {
8787
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
88-
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
88+
self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id));
8989
}
9090
if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
91-
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
91+
self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id));
9292
}
9393
}
9494
}
@@ -97,10 +97,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
9797
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
9898
if let PlaceBase::Local(id) = cmt.place.base {
9999
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
100-
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
100+
self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id));
101101
}
102102
if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
103-
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
103+
self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id));
104104
}
105105
}
106106
}

clippy_lints/src/macro_metavars_in_unsafe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
253253
// Remove the syntax context to hide "in this macro invocation" in the diagnostic.
254254
// The invocation doesn't matter. Also we want to dedupe by the unsafe block and not by anything
255255
// related to the callsite.
256-
let span = cx.tcx.hir().span(id);
256+
let span = cx.tcx.hir_span(id);
257257

258258
(id, Span::new(span.lo(), span.hi(), SyntaxContext::root(), None))
259259
})

clippy_lints/src/misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
329329
let name = ident.name.as_str();
330330
if name.starts_with('_')
331331
&& !name.starts_with("__")
332-
&& let definition_span = cx.tcx.hir().span(definition_hir_id)
332+
&& let definition_span = cx.tcx.hir_span(definition_hir_id)
333333
&& !definition_span.from_expansion()
334334
&& !fulfill_or_allowed(cx, USED_UNDERSCORE_BINDING, [expr.hir_id, definition_hir_id])
335335
{

clippy_lints/src/needless_pass_by_ref_mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
280280
diag.span_suggestion(
281281
sp,
282282
"consider changing to".to_string(),
283-
format!("&{}", snippet(cx, cx.tcx.hir().span(inner_ty.ty.hir_id), "_"),),
283+
format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),),
284284
Applicability::Unspecified,
285285
);
286286
if cx.effective_visibilities.is_exported(*fn_def_id) {

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
198198
// Dereference suggestion
199199
let sugg = |diag: &mut Diag<'_, ()>| {
200200
if let ty::Adt(def, ..) = ty.kind() {
201-
if let Some(span) = cx.tcx.hir().span_if_local(def.did()) {
201+
if let Some(span) = cx.tcx.hir_span_if_local(def.did()) {
202202
if type_allowed_to_implement_copy(
203203
cx.tcx,
204204
cx.param_env,

clippy_lints/src/operators/arithmetic_side_effects.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
354354

355355
let body_owner_kind = cx.tcx.hir_body_owner_kind(body_owner_def_id);
356356
if let hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) = body_owner_kind {
357-
let body_span = cx.tcx.hir().span_with_body(body_owner);
357+
let body_span = cx.tcx.hir_span_with_body(body_owner);
358358
if let Some(span) = self.const_span
359359
&& span.contains(body_span)
360360
{
@@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
366366

367367
fn check_body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
368368
let body_owner = cx.tcx.hir_body_owner(body.id());
369-
let body_span = cx.tcx.hir().span(body_owner);
369+
let body_span = cx.tcx.hir_span(body_owner);
370370
if let Some(span) = self.const_span
371371
&& span.contains(body_span)
372372
{

clippy_lints/src/operators/numeric_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Context {
7373

7474
match cx.tcx.hir_body_owner_kind(body_owner_def_id) {
7575
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const { .. } => {
76-
let body_span = cx.tcx.hir().span_with_body(body_owner);
76+
let body_span = cx.tcx.hir_span_with_body(body_owner);
7777

7878
if let Some(span) = self.const_span {
7979
if span.contains(body_span) {
@@ -88,7 +88,7 @@ impl Context {
8888

8989
pub fn body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
9090
let body_owner = cx.tcx.hir_body_owner(body.id());
91-
let body_span = cx.tcx.hir().span_with_body(body_owner);
91+
let body_span = cx.tcx.hir_span_with_body(body_owner);
9292

9393
if let Some(span) = self.const_span {
9494
if span.contains(body_span) {

clippy_lints/src/shadow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span)
218218
},
219219
};
220220
span_lint_and_then(cx, lint, span, msg, |diag| {
221-
diag.span_note(cx.tcx.hir().span(shadowed), "previous binding is here");
221+
diag.span_note(cx.tcx.hir_span(shadowed), "previous binding is here");
222222
});
223223
}
224224

clippy_lints/src/single_call_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn {
137137
for (&def_id, usage) in &self.def_id_to_usage {
138138
if let CallState::Once { call_site } = *usage
139139
&& let fn_hir_id = cx.tcx.local_def_id_to_hir_id(def_id)
140-
&& let fn_span = cx.tcx.hir().span_with_body(fn_hir_id)
140+
&& let fn_span = cx.tcx.hir_span_with_body(fn_hir_id)
141141
&& !self.is_function_allowed(cx, def_id, fn_hir_id, fn_span)
142142
{
143143
span_lint_hir_and_then(

clippy_utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
29902990
{
29912991
adjustments = cx.typeck_results().expr_adjustments(e);
29922992
}
2993-
same_ctxt &= cx.tcx.hir().span(parent_id).ctxt() == ctxt;
2993+
same_ctxt &= cx.tcx.hir_span(parent_id).ctxt() == ctxt;
29942994
if let Node::Expr(e) = parent {
29952995
match e.kind {
29962996
ExprKind::If(e, _, _) | ExprKind::Match(e, _, _) if e.hir_id != child_id => {

clippy_utils/src/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option<
178178

179179
// get the parent node, possibly skipping over a statement
180180
// if the parent is not found, it is sensible to return `Some(root)`
181-
let hir = cx.tcx.hir();
182181
let mut parent_iter = cx.tcx.hir_parent_iter(node.hir_id());
183182
let (parent_id, _) = match parent_iter.next() {
184183
None => return Some(ExpnId::root()),
@@ -190,7 +189,7 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option<
190189
};
191190

192191
// get the macro expansion of the parent node
193-
let parent_span = hir.span(parent_id);
192+
let parent_span = cx.tcx.hir_span(parent_id);
194193
let Some(parent_macro_call) = macro_backtrace(parent_span).next() else {
195194
// the parent node is not in a macro
196195
return Some(ExpnId::root());

clippy_utils/src/sugg.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
839839

840840
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
841841
if let PlaceBase::Local(id) = cmt.place.base {
842-
let map = self.cx.tcx.hir();
843-
let span = map.span(cmt.hir_id);
842+
let span = self.cx.tcx.hir_span(cmt.hir_id);
844843
let start_span = Span::new(self.next_pos, span.lo(), span.ctxt(), None);
845844
let mut start_snip = snippet_with_applicability(self.cx, start_span, "..", &mut self.applicability);
846845

0 commit comments

Comments
 (0)