Skip to content

Commit 0aea3ed

Browse files
committed
Avoid lots of hir::HirId{,Map,Set} qualifiers.
Because they're a bit redundant.
1 parent c0bc812 commit 0aea3ed

File tree

5 files changed

+37
-35
lines changed

5 files changed

+37
-35
lines changed

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::{self as hir, intravisit, HirIdSet};
1+
use rustc_hir::{self as hir, intravisit, HirId, HirIdSet};
22
use rustc_lint::LateContext;
33
use rustc_middle::ty;
44
use rustc_span::def_id::LocalDefId;
@@ -74,7 +74,7 @@ fn check_raw_ptr<'tcx>(
7474
}
7575
}
7676

77-
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<hir::HirId> {
77+
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<HirId> {
7878
if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_, _))) = (
7979
&arg.pat.kind,
8080
cx.maybe_typeck_results()

clippy_lints/src/index_refutable_slice.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local};
77
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
88
use rustc_errors::Applicability;
99
use rustc_hir as hir;
10+
use rustc_hir::HirId;
1011
use rustc_hir::intravisit::{self, Visitor};
1112
use rustc_lint::{LateContext, LateLintPass};
1213
use rustc_middle::hir::nested_filter;
@@ -87,9 +88,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
8788
extract_msrv_attr!(LateContext);
8889
}
8990

90-
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<hir::HirId, SliceLintInformation> {
91-
let mut removed_pat: FxHashSet<hir::HirId> = FxHashSet::default();
92-
let mut slices: FxIndexMap<hir::HirId, SliceLintInformation> = FxIndexMap::default();
91+
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<HirId, SliceLintInformation> {
92+
let mut removed_pat: FxHashSet<HirId> = FxHashSet::default();
93+
let mut slices: FxIndexMap<HirId, SliceLintInformation> = FxIndexMap::default();
9394
pat.walk_always(|pat| {
9495
// We'll just ignore mut and ref mut for simplicity sake right now
9596
if let hir::PatKind::Binding(
@@ -206,10 +207,10 @@ impl SliceLintInformation {
206207

207208
fn filter_lintable_slices<'tcx>(
208209
cx: &LateContext<'tcx>,
209-
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
210+
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
210211
max_suggested_slice: u64,
211212
scope: &'tcx hir::Expr<'tcx>,
212-
) -> FxIndexMap<hir::HirId, SliceLintInformation> {
213+
) -> FxIndexMap<HirId, SliceLintInformation> {
213214
let mut visitor = SliceIndexLintingVisitor {
214215
cx,
215216
slice_lint_info,
@@ -223,7 +224,7 @@ fn filter_lintable_slices<'tcx>(
223224

224225
struct SliceIndexLintingVisitor<'a, 'tcx> {
225226
cx: &'a LateContext<'tcx>,
226-
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
227+
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
227228
max_suggested_slice: u64,
228229
}
229230

clippy_lints/src/operators/assign_op_pattern.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clippy_utils::{binop_traits, eq_expr_value, trait_ref_of_method};
66
use core::ops::ControlFlow;
77
use rustc_errors::Applicability;
88
use rustc_hir as hir;
9+
use rustc_hir::{HirId, HirIdSet};
910
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1011
use rustc_lint::LateContext;
1112
use rustc_middle::mir::FakeReadCause;
@@ -98,10 +99,10 @@ pub(super) fn check<'tcx>(
9899
}
99100
}
100101

101-
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
102-
struct S(hir::HirIdSet);
102+
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
103+
struct S(HirIdSet);
103104
impl Delegate<'_> for S {
104-
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
105+
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
105106
if matches!(kind, BorrowKind::ImmBorrow | BorrowKind::UniqueImmBorrow) {
106107
self.0.insert(match place.place.base {
107108
PlaceBase::Local(id) => id,
@@ -111,13 +112,13 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
111112
}
112113
}
113114

114-
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
115-
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
116-
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
117-
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
115+
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
116+
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
117+
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
118+
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
118119
}
119120

120-
let mut s = S(hir::HirIdSet::default());
121+
let mut s = S(HirIdSet::default());
121122
let infcx = cx.tcx.infer_ctxt().build();
122123
let mut v = ExprUseVisitor::new(
123124
&mut s,
@@ -130,10 +131,10 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
130131
s.0
131132
}
132133

133-
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
134-
struct S(hir::HirIdSet);
134+
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
135+
struct S(HirIdSet);
135136
impl Delegate<'_> for S {
136-
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
137+
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
137138
if matches!(kind, BorrowKind::MutBorrow) {
138139
self.0.insert(match place.place.base {
139140
PlaceBase::Local(id) => id,
@@ -143,13 +144,13 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
143144
}
144145
}
145146

146-
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
147-
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
148-
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
149-
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
147+
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
148+
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
149+
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
150+
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
150151
}
151152

152-
let mut s = S(hir::HirIdSet::default());
153+
let mut s = S(HirIdSet::default());
153154
let infcx = cx.tcx.infer_ctxt().build();
154155
let mut v = ExprUseVisitor::new(
155156
&mut s,

clippy_lints/src/ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clippy_utils::{get_expr_use_or_unification_node, is_lint_allowed, path_def_i
88
use hir::LifetimeName;
99
use rustc_errors::{Applicability, MultiSpan};
1010
use rustc_hir::def_id::DefId;
11-
use rustc_hir::hir_id::HirIdMap;
11+
use rustc_hir::hir_id::{HirId, HirIdMap};
1212
use rustc_hir::intravisit::{walk_expr, Visitor};
1313
use rustc_hir::{
1414
self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg,
@@ -324,7 +324,7 @@ struct PtrArgReplacement {
324324

325325
struct PtrArg<'tcx> {
326326
idx: usize,
327-
emission_id: hir::HirId,
327+
emission_id: HirId,
328328
span: Span,
329329
ty_did: DefId,
330330
ty_name: Symbol,

clippy_lints/src/significant_drop_tightening.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::intravisit::{walk_expr, Visitor};
8-
use rustc_hir::{self as hir};
8+
use rustc_hir::{self as hir, HirId};
99
use rustc_lint::{LateContext, LateLintPass, LintContext};
1010
use rustc_middle::ty::{GenericArgKind, Ty};
1111
use rustc_session::impl_lint_pass;
@@ -55,7 +55,7 @@ impl_lint_pass!(SignificantDropTightening<'_> => [SIGNIFICANT_DROP_TIGHTENING]);
5555

5656
#[derive(Default)]
5757
pub struct SignificantDropTightening<'tcx> {
58-
apas: FxIndexMap<hir::HirId, AuxParamsAttr>,
58+
apas: FxIndexMap<HirId, AuxParamsAttr>,
5959
/// Auxiliary structure used to avoid having to verify the same type multiple times.
6060
seen_types: FxHashSet<Ty<'tcx>>,
6161
type_cache: FxHashMap<Ty<'tcx>, bool>,
@@ -359,20 +359,20 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o
359359
/// Auxiliary parameters used on each block check of an item
360360
struct AuxParams<'others, 'stmt, 'tcx> {
361361
//// See [AuxParamsAttr].
362-
apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>,
362+
apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>,
363363
/// The current block identifier that is being visited.
364-
curr_block_hir_id: hir::HirId,
364+
curr_block_hir_id: HirId,
365365
/// The current block span that is being visited.
366366
curr_block_span: Span,
367367
/// The current statement that is being visited.
368368
curr_stmt: Cow<'stmt, hir::Stmt<'tcx>>,
369369
}
370370

371371
impl<'others, 'stmt, 'tcx> AuxParams<'others, 'stmt, 'tcx> {
372-
fn new(apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
372+
fn new(apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
373373
Self {
374374
apas,
375-
curr_block_hir_id: hir::HirId::INVALID,
375+
curr_block_hir_id: HirId::INVALID,
376376
curr_block_span: DUMMY_SP,
377377
curr_stmt: Cow::Borrowed(curr_stmt),
378378
}
@@ -389,7 +389,7 @@ struct AuxParamsAttr {
389389
has_expensive_expr_after_last_attr: bool,
390390

391391
/// The identifier of the block that involves the first `#[has_significant_drop]`.
392-
first_block_hir_id: hir::HirId,
392+
first_block_hir_id: HirId,
393393
/// The span of the block that involves the first `#[has_significant_drop]`.
394394
first_block_span: Span,
395395
/// The binding or variable that references the initial construction of the type marked with
@@ -414,7 +414,7 @@ impl Default for AuxParamsAttr {
414414
Self {
415415
counter: 0,
416416
has_expensive_expr_after_last_attr: false,
417-
first_block_hir_id: hir::HirId::INVALID,
417+
first_block_hir_id: HirId::INVALID,
418418
first_bind_ident: Ident::empty(),
419419
first_block_span: DUMMY_SP,
420420
first_method_span: DUMMY_SP,
@@ -428,7 +428,7 @@ impl Default for AuxParamsAttr {
428428

429429
fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
430430
hir::Stmt {
431-
hir_id: hir::HirId::INVALID,
431+
hir_id: HirId::INVALID,
432432
kind: hir::StmtKind::Expr(expr),
433433
span: DUMMY_SP,
434434
}

0 commit comments

Comments
 (0)