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

5 files changed

Lines changed: 37 additions & 35 deletions

File tree

‎clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::{selfas hir, intravisit,HirIdSet};
1+
use rustc_hir::{selfas 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-
fnraw_ptr_arg(cx:&LateContext<'_>,arg:&hir::Param<'_>) -> Option<hir::HirId>{
77+
fnraw_ptr_arg(cx:&LateContext<'_>,arg:&hir::Param<'_>) -> Option<HirId>{
7878
iflet(&hir::PatKind::Binding(_, id, _, _),Some(&ty::RawPtr(_, _))) = (
7979
&arg.pat.kind,
8080
cx.maybe_typeck_results()

‎clippy_lints/src/index_refutable_slice.rs‎

Lines changed: 7 additions & 6 deletions
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-
fnfind_slice_values(cx:&LateContext<'_>,pat:&hir::Pat<'_>) -> FxIndexMap<hir::HirId,SliceLintInformation>{
91-
letmut removed_pat:FxHashSet<hir::HirId> = FxHashSet::default();
92-
letmut slices:FxIndexMap<hir::HirId,SliceLintInformation> = FxIndexMap::default();
91+
fnfind_slice_values(cx:&LateContext<'_>,pat:&hir::Pat<'_>) -> FxIndexMap<HirId,SliceLintInformation>{
92+
letmut removed_pat:FxHashSet<HirId> = FxHashSet::default();
93+
letmut 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
iflet hir::PatKind::Binding(
@@ -206,10 +207,10 @@ impl SliceLintInformation {
206207

207208
fnfilter_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
letmut visitor = SliceIndexLintingVisitor{
214215
cx,
215216
slice_lint_info,
@@ -223,7 +224,7 @@ fn filter_lintable_slices<'tcx>(
223224

224225
structSliceIndexLintingVisitor<'a,'tcx>{
225226
cx:&'aLateContext<'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‎

Lines changed: 17 additions & 16 deletions
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-
fnimm_borrows_in_expr(cx:&LateContext<'_>,e:&hir::Expr<'_>) -> hir::HirIdSet{
102-
structS(hir::HirIdSet);
102+
fnimm_borrows_in_expr(cx:&LateContext<'_>,e:&hir::Expr<'_>) -> HirIdSet{
103+
structS(HirIdSet);
103104
implDelegate<'_>forS{
104-
fnborrow(&mutself,place:&PlaceWithHirId<'_>, _:hir::HirId,kind:BorrowKind){
105+
fnborrow(&mutself,place:&PlaceWithHirId<'_>, _:HirId,kind:BorrowKind){
105106
ifmatches!(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-
fnconsume(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
115-
fnmutate(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
116-
fnfake_read(&mutself, _:&PlaceWithHirId<'_>, _:FakeReadCause, _:hir::HirId){}
117-
fncopy(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
115+
fnconsume(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
116+
fnmutate(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
117+
fnfake_read(&mutself, _:&PlaceWithHirId<'_>, _:FakeReadCause, _:HirId){}
118+
fncopy(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
118119
}
119120

120-
letmut s = S(hir::HirIdSet::default());
121+
letmut s = S(HirIdSet::default());
121122
let infcx = cx.tcx.infer_ctxt().build();
122123
letmut 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-
fnmut_borrows_in_expr(cx:&LateContext<'_>,e:&hir::Expr<'_>) -> hir::HirIdSet{
134-
structS(hir::HirIdSet);
134+
fnmut_borrows_in_expr(cx:&LateContext<'_>,e:&hir::Expr<'_>) -> HirIdSet{
135+
structS(HirIdSet);
135136
implDelegate<'_>forS{
136-
fnborrow(&mutself,place:&PlaceWithHirId<'_>, _:hir::HirId,kind:BorrowKind){
137+
fnborrow(&mutself,place:&PlaceWithHirId<'_>, _:HirId,kind:BorrowKind){
137138
ifmatches!(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-
fnconsume(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
147-
fnmutate(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
148-
fnfake_read(&mutself, _:&PlaceWithHirId<'_>, _:FakeReadCause, _:hir::HirId){}
149-
fncopy(&mutself, _:&PlaceWithHirId<'_>, _:hir::HirId){}
147+
fnconsume(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
148+
fnmutate(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
149+
fnfake_read(&mutself, _:&PlaceWithHirId<'_>, _:FakeReadCause, _:HirId){}
150+
fncopy(&mutself, _:&PlaceWithHirId<'_>, _:HirId){}
150151
}
151152

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

‎clippy_lints/src/ptr.rs‎

Lines changed: 2 additions & 2 deletions
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
selfas hir,AnonConst,BinOpKind,BindingAnnotation,Body,Expr,ExprKind,FnRetTy,FnSig,GenericArg,
@@ -324,7 +324,7 @@ struct PtrArgReplacement {
324324

325325
structPtrArg<'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‎

Lines changed: 9 additions & 9 deletions
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::{selfas hir};
8+
use rustc_hir::{selfas 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
pubstructSignificantDropTightening<'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
structAuxParams<'others,'stmt,'tcx>{
361361
//// See [AuxParamsAttr].
362-
apas:&'othersmutFxIndexMap<hir::HirId,AuxParamsAttr>,
362+
apas:&'othersmutFxIndexMap<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-
fnnew(apas:&'othersmutFxIndexMap<hir::HirId,AuxParamsAttr>,curr_stmt:&'stmt hir::Stmt<'tcx>) -> Self{
372+
fnnew(apas:&'othersmutFxIndexMap<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
fndummy_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)