From 1efb5513699c2873c09caf59451628317d03f68b Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Thu, 1 Apr 2021 09:51:31 -0500 Subject: [PATCH 1/2] Remove get_node_span --- clippy_utils/src/lib.rs | 44 ++++------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 7ce90ffd9f0..0dce0cb5d67 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -60,10 +60,9 @@ use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{ - def, Arm, BindingAnnotation, Block, Body, Constness, CrateItem, Expr, ExprKind, FieldDef, FnDecl, ForeignItem, - GenericArgs, GenericParam, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind, LangItem, Lifetime, Local, - MacroDef, MatchSource, Node, Param, Pat, PatKind, Path, PathSegment, QPath, Stmt, TraitItem, TraitItemKind, - TraitRef, TyKind, Variant, Visibility, + def, Arm, BindingAnnotation, Block, Body, Constness, Expr, ExprKind, FnDecl, GenericArgs, HirId, Impl, ImplItem, + ImplItemKind, Item, ItemKind, LangItem, MatchSource, Node, Param, Pat, PatKind, Path, PathSegment, QPath, + TraitItem, TraitItemKind, TraitRef, TyKind, }; use rustc_lint::{LateContext, Level, Lint, LintContext}; use rustc_middle::hir::exports::Export; @@ -75,7 +74,7 @@ use rustc_session::Session; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::original_sp; use rustc_span::sym; -use rustc_span::symbol::{kw, Ident, Symbol}; +use rustc_span::symbol::{kw, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::Integer; @@ -712,41 +711,6 @@ fn line_span(cx: &T, span: Span) -> Span { Span::new(line_start, span.hi(), span.ctxt()) } -/// Gets the span of the node, if there is one. -pub fn get_node_span(node: Node<'_>) -> Option { - match node { - Node::Param(Param { span, .. }) - | Node::Item(Item { span, .. }) - | Node::ForeignItem(ForeignItem { span, .. }) - | Node::TraitItem(TraitItem { span, .. }) - | Node::ImplItem(ImplItem { span, .. }) - | Node::Variant(Variant { span, .. }) - | Node::Field(FieldDef { span, .. }) - | Node::Expr(Expr { span, .. }) - | Node::Stmt(Stmt { span, .. }) - | Node::PathSegment(PathSegment { - ident: Ident { span, .. }, - .. - }) - | Node::Ty(hir::Ty { span, .. }) - | Node::TraitRef(TraitRef { - path: Path { span, .. }, - .. - }) - | Node::Binding(Pat { span, .. }) - | Node::Pat(Pat { span, .. }) - | Node::Arm(Arm { span, .. }) - | Node::Block(Block { span, .. }) - | Node::Local(Local { span, .. }) - | Node::MacroDef(MacroDef { span, .. }) - | Node::Lifetime(Lifetime { span, .. }) - | Node::GenericParam(GenericParam { span, .. }) - | Node::Visibility(Visibility { span, .. }) - | Node::Crate(CrateItem { span, .. }) => Some(*span), - Node::Ctor(_) | Node::AnonConst(_) => None, - } -} - /// Gets the parent node, if any. pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option> { tcx.hir().parent_iter(id).next().map(|(_, node)| node) From 79d3082cd779ccae785dbec906005af92ff36b1a Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Thu, 1 Apr 2021 10:24:44 -0500 Subject: [PATCH 2/2] Remove paths::PATH_BUF --- clippy_utils/src/paths.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/clippy_utils/src/paths.rs b/clippy_utils/src/paths.rs index 7c83a9fe4e2..3b4c4070c0e 100644 --- a/clippy_utils/src/paths.rs +++ b/clippy_utils/src/paths.rs @@ -93,7 +93,6 @@ pub(super) const PANIC_ANY: [&str; 3] = ["std", "panic", "panic_any"]; pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"]; pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 2] = ["parking_lot", "RwLockReadGuard"]; pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWriteGuard"]; -pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"]; pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"]; pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"]; pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"];