mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 17:33:07 +00:00
Don't lint single_component_path_imports
in macros
This commit is contained in:
parent
578960d61d
commit
09165ff576
@ -1,4 +1,4 @@
|
|||||||
use crate::utils::span_lint_and_sugg;
|
use crate::utils::{in_macro, span_lint_and_sugg};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||||
@ -39,6 +39,7 @@ declare_lint_pass!(SingleComponentPathImports => [SINGLE_COMPONENT_PATH_IMPORTS]
|
|||||||
impl EarlyLintPass for SingleComponentPathImports {
|
impl EarlyLintPass for SingleComponentPathImports {
|
||||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
|
if !in_macro(item.span);
|
||||||
if cx.sess.opts.edition == Edition::Edition2018;
|
if cx.sess.opts.edition == Edition::Edition2018;
|
||||||
if !item.vis.node.is_pub();
|
if !item.vis.node.is_pub();
|
||||||
if let ItemKind::Use(use_tree) = &item.kind;
|
if let ItemKind::Use(use_tree) = &item.kind;
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
use serde as edres;
|
use serde as edres;
|
||||||
pub use serde;
|
pub use serde;
|
||||||
|
|
||||||
|
macro_rules! m {
|
||||||
|
() => {
|
||||||
|
use regex;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
|
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
|
||||||
|
|
||||||
|
// False positive #5154, shouldn't trigger lint.
|
||||||
|
m!();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,15 @@ use regex;
|
|||||||
use serde as edres;
|
use serde as edres;
|
||||||
pub use serde;
|
pub use serde;
|
||||||
|
|
||||||
|
macro_rules! m {
|
||||||
|
() => {
|
||||||
|
use regex;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
|
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
|
||||||
|
|
||||||
|
// False positive #5154, shouldn't trigger lint.
|
||||||
|
m!();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user