Skip to content

Commit 99fdf26

Browse files
committed
Auto merge of #3873 - phansch:hiridification, r=flip1995
Some more HirId-ification * 8a59f81: Rename span_lint_node* functions to span_lint_hir* * a457258: Use `HirId` instead of `NodeId` for lookup
2 parents 8fc0a73 + bf86c1b commit 99fdf26

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

clippy_lints/src/escape.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
122122
return;
123123
}
124124
if let Categorization::Rvalue(..) = cmt.cat {
125-
let id = map.hir_to_node_id(cmt.hir_id);
126-
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) {
125+
if let Some(Node::Stmt(st)) = map.find_by_hir_id(map.get_parent_node_by_hir_id(cmt.hir_id)) {
127126
if let StmtKind::Local(ref loc) = st.node {
128127
if let Some(ref ex) = loc.init {
129128
if let ExprKind::Box(..) = ex.node {

clippy_lints/src/new_without_default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::paths;
22
use crate::utils::sugg::DiagnosticBuilderExt;
3-
use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_node_and_then};
3+
use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_hir_and_then};
44
use if_chain::if_chain;
55
use rustc::hir;
66
use rustc::hir::def_id::DefId;
@@ -163,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
163163
}
164164

165165
if let Some(sp) = can_derive_default(self_ty, cx, default_trait_id) {
166-
span_lint_node_and_then(
166+
span_lint_hir_and_then(
167167
cx,
168168
NEW_WITHOUT_DEFAULT,
169169
id,
@@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
182182
);
183183
});
184184
} else {
185-
span_lint_node_and_then(
185+
span_lint_hir_and_then(
186186
cx,
187187
NEW_WITHOUT_DEFAULT,
188188
id,

clippy_lints/src/partialeq_ne_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{is_automatically_derived, span_lint_node};
1+
use crate::utils::{is_automatically_derived, span_lint_hir};
22
use if_chain::if_chain;
33
use rustc::hir::*;
44
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5151
then {
5252
for impl_item in impl_items {
5353
if impl_item.ident.name == "ne" {
54-
span_lint_node(
54+
span_lint_hir(
5555
cx,
5656
PARTIALEQ_NE_IMPL,
5757
impl_item.id.hir_id,

clippy_lints/src/redundant_clone.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
2-
has_drop, in_macro, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_node,
3-
span_lint_node_and_then, walk_ptrs_ty_depth,
2+
has_drop, in_macro, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_hir, span_lint_hir_and_then,
3+
walk_ptrs_ty_depth,
44
};
55
use if_chain::if_chain;
66
use matches::matches;
@@ -199,7 +199,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
199199
span.lo() + BytePos(u32::try_from(dot).unwrap())
200200
);
201201

202-
span_lint_node_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| {
202+
span_lint_hir_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| {
203203
db.span_suggestion(
204204
sugg_span,
205205
"remove this",
@@ -212,7 +212,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
212212
);
213213
});
214214
} else {
215-
span_lint_node(cx, REDUNDANT_CLONE, node, span, "redundant clone");
215+
span_lint_hir(cx, REDUNDANT_CLONE, node, span, "redundant clone");
216216
}
217217
}
218218
}

clippy_lints/src/utils/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
134134
db.docs_link(lint);
135135
}
136136

137-
pub fn span_lint_node(cx: &LateContext<'_, '_>, lint: &'static Lint, node: HirId, sp: Span, msg: &str) {
138-
DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, node, sp, msg)).docs_link(lint);
137+
pub fn span_lint_hir(cx: &LateContext<'_, '_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) {
138+
DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg)).docs_link(lint);
139139
}
140140

141-
pub fn span_lint_node_and_then(
141+
pub fn span_lint_hir_and_then(
142142
cx: &LateContext<'_, '_>,
143143
lint: &'static Lint,
144-
node: HirId,
144+
hir_id: HirId,
145145
sp: Span,
146146
msg: &str,
147147
f: impl FnOnce(&mut DiagnosticBuilder<'_>),
148148
) {
149-
let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, node, sp, msg));
149+
let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg));
150150
f(&mut db.0);
151151
db.docs_link(lint);
152152
}

0 commit comments

Comments
 (0)