Skip to content

Commit f7f9b94

Browse files
committed
Exclude reexport imports.
1 parent 4c63760 commit f7f9b94

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

clippy_lints/src/single_component_path_imports.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ declare_clippy_lint! {
2222
/// fn main() {
2323
/// regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
2424
/// }
25-
///```
25+
/// ```
26+
/// Better as
27+
/// ```rust, ignore
28+
/// fn main() {
29+
/// regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
30+
/// }
31+
/// ```
2632
pub SINGLE_COMPONENT_PATH_IMPORTS,
2733
style,
2834
"imports with single component path are redundant"
@@ -34,6 +40,7 @@ impl EarlyLintPass for SingleComponentPathImports {
3440
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
3541
if_chain! {
3642
if cx.sess.opts.edition == Edition::Edition2018;
43+
if !item.vis.node.is_pub();
3744
if let ItemKind::Use(use_tree) = &item.kind;
3845
if let segments = &use_tree.prefix.segments;
3946
if segments.len() == 1;

tests/ui/single_component_path_imports.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![warn(clippy::single_component_path_imports)]
44

55

6+
use serde as edres;
7+
pub use serde;
68

79
fn main() {
810
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();

tests/ui/single_component_path_imports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use regex;
66
use serde as edres;
7+
pub use serde;
78

89
fn main() {
910
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();

0 commit comments

Comments
 (0)