Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more HirId-ification #3873

Merged
merged 3 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
return;
}
if let Categorization::Rvalue(..) = cmt.cat {
let id = map.hir_to_node_id(cmt.hir_id);
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) {
if let Some(Node::Stmt(st)) = map.find_by_hir_id(map.get_parent_node_by_hir_id(cmt.hir_id)) {
if let StmtKind::Local(ref loc) = st.node {
if let Some(ref ex) = loc.init {
if let ExprKind::Box(..) = ex.node {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::paths;
use crate::utils::sugg::DiagnosticBuilderExt;
use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_node_and_then};
use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_hir_and_then};
use if_chain::if_chain;
use rustc::hir;
use rustc::hir::def_id::DefId;
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
}

if let Some(sp) = can_derive_default(self_ty, cx, default_trait_id) {
span_lint_node_and_then(
span_lint_hir_and_then(
cx,
NEW_WITHOUT_DEFAULT,
id,
Expand All @@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
);
});
} else {
span_lint_node_and_then(
span_lint_hir_and_then(
cx,
NEW_WITHOUT_DEFAULT,
id,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/partialeq_ne_impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::utils::{is_automatically_derived, span_lint_node};
use crate::utils::{is_automatically_derived, span_lint_hir};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
then {
for impl_item in impl_items {
if impl_item.ident.name == "ne" {
span_lint_node(
span_lint_hir(
cx,
PARTIALEQ_NE_IMPL,
impl_item.id.hir_id,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::{
has_drop, in_macro, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_node,
span_lint_node_and_then, walk_ptrs_ty_depth,
has_drop, in_macro, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_hir, span_lint_hir_and_then,
walk_ptrs_ty_depth,
};
use if_chain::if_chain;
use matches::matches;
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
span.lo() + BytePos(u32::try_from(dot).unwrap())
);

span_lint_node_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| {
span_lint_hir_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| {
db.span_suggestion(
sugg_span,
"remove this",
Expand All @@ -212,7 +212,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
);
});
} else {
span_lint_node(cx, REDUNDANT_CLONE, node, span, "redundant clone");
span_lint_hir(cx, REDUNDANT_CLONE, node, span, "redundant clone");
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/utils/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
db.docs_link(lint);
}

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

pub fn span_lint_node_and_then(
pub fn span_lint_hir_and_then(
cx: &LateContext<'_, '_>,
lint: &'static Lint,
node: HirId,
hir_id: HirId,
sp: Span,
msg: &str,
f: impl FnOnce(&mut DiagnosticBuilder<'_>),
) {
let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, node, sp, msg));
let mut db = DiagnosticWrapper(cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg));
f(&mut db.0);
db.docs_link(lint);
}
Expand Down