Skip to content

Commit

Permalink
Restrict lint logic.
Browse files Browse the repository at this point in the history
Restrict lint logic to apply on edition2018 only.
  • Loading branch information
xiongmao86 committed Jan 25, 2020
1 parent 37abf6d commit d9f9278
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clippy_lints/src/single_component_use_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
use syntax::ast::{Item, ItemKind};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_span::edition::Edition;

declare_clippy_lint! {
/// **What it does:** Checking for imports with single component use path.
Expand Down Expand Up @@ -32,6 +33,7 @@ declare_lint_pass!(SingleComponentUsePath => [SINGLE_COMPONENT_USE_PATH]);
impl EarlyLintPass for SingleComponentUsePath {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if_chain! {
if cx.sess.opts.edition == Edition::Edition2018;
if let ItemKind::Use(use_tree) = &item.kind;
if let segments = &use_tree.prefix.segments;
if segments.len() == 1;
Expand Down

0 comments on commit d9f9278

Please sign in to comment.