Skip to content

Commit ec98e53

Browse files
committed
Auto merge of rust-lang#4216 - phansch:replace_nodeset, r=matthiaskrgr
Refactor: Replace NodeSet with HirIdSet This saves us one HirId -> NodeId conversion. changelog: none
2 parents 868f168 + ebce573 commit ec98e53

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

clippy_lints/src/new_without_default.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::hir;
66
use rustc::hir::def_id::DefId;
77
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
88
use rustc::ty::{self, Ty};
9-
use rustc::util::nodemap::NodeSet;
9+
use rustc::util::nodemap::HirIdSet;
1010
use rustc::{declare_tool_lint, impl_lint_pass};
1111
use rustc_errors::Applicability;
1212
use syntax::source_map::Span;
@@ -86,7 +86,7 @@ declare_clippy_lint! {
8686

8787
#[derive(Clone, Default)]
8888
pub struct NewWithoutDefault {
89-
impling_types: Option<NodeSet>,
89+
impling_types: Option<HirIdSet>,
9090
}
9191

9292
impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);
@@ -128,11 +128,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
128128
if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT);
129129
then {
130130
if self.impling_types.is_none() {
131-
let mut impls = NodeSet::default();
131+
let mut impls = HirIdSet::default();
132132
cx.tcx.for_each_impl(default_trait_id, |d| {
133133
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
134-
if let Some(node_id) = cx.tcx.hir().as_local_node_id(ty_def.did) {
135-
impls.insert(node_id);
134+
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(ty_def.did) {
135+
impls.insert(hir_id);
136136
}
137137
}
138138
});
@@ -147,8 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
147147
if self_def.did.is_local();
148148
then {
149149
let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_def.did.to_local());
150-
let node_id = cx.tcx.hir().hir_to_node_id(self_id);
151-
if impling_types.contains(&node_id) {
150+
if impling_types.contains(&self_id) {
152151
return;
153152
}
154153
}

0 commit comments

Comments
 (0)