diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index d00d8dfbd3ed..6e5015eb8449 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -2310,7 +2310,7 @@ fn lint_unwrap(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, unwrap_args: &[hi &format!("used `unwrap()` on `{}` value", kind,), &format!( "if you don't want to handle the `{}` case gracefully, consider \ - using `expect()` to provide a better panic message", + using `expect()` to provide a better panic message", none_value, ), ); @@ -2679,7 +2679,7 @@ fn lint_filter_flat_map<'a, 'tcx>( if match_trait_method(cx, expr, &paths::ITERATOR) { let msg = "called `filter(p).flat_map(q)` on an `Iterator`"; let hint = "this is more succinctly expressed by calling `.flat_map(..)` \ - and filtering by returning `iter::empty()`"; + and filtering by returning `iter::empty()`"; span_lint_and_help(cx, FILTER_MAP, expr.span, msg, hint); } } @@ -2695,7 +2695,7 @@ fn lint_filter_map_flat_map<'a, 'tcx>( if match_trait_method(cx, expr, &paths::ITERATOR) { let msg = "called `filter_map(p).flat_map(q)` on an `Iterator`"; let hint = "this is more succinctly expressed by calling `.flat_map(..)` \ - and filtering by returning `iter::empty()`"; + and filtering by returning `iter::empty()`"; span_lint_and_help(cx, FILTER_MAP, expr.span, msg, hint); } } @@ -3148,7 +3148,7 @@ fn lint_option_as_ref_deref<'a, 'tcx>( let msg = format!( "called `{0}` (or with one of deref aliases) on an Option value. \ - This can be done more directly by calling `{1}` instead", + This can be done more directly by calling `{1}` instead", current_method, hint ); span_lint_and_sugg( diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 2ff6562666ba..25e79b6fa01a 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -22,7 +22,13 @@ declare_clippy_lint! { /// fn main() { /// regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); /// } - ///``` + /// ``` + /// Better as + /// ```rust, ignore + /// fn main() { + /// regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); + /// } + /// ``` pub SINGLE_COMPONENT_PATH_IMPORTS, style, "imports with single component path are redundant" @@ -34,6 +40,7 @@ impl EarlyLintPass for SingleComponentPathImports { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { if_chain! { if cx.sess.opts.edition == Edition::Edition2018; + if !item.vis.node.is_pub(); if let ItemKind::Use(use_tree) = &item.kind; if let segments = &use_tree.prefix.segments; if segments.len() == 1; diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 4fcf39d21428..e47f2480a541 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -316,7 +316,7 @@ impl Types { OPTION_OPTION, hir_ty.span, "consider using `Option` instead of `Option>` or a custom \ - enum if you need to distinguish all 3 cases", + enum if you need to distinguish all 3 cases", ); return; // don't recurse into the type } diff --git a/tests/ui/single_component_path_imports.fixed b/tests/ui/single_component_path_imports.fixed index bfd97ef5f6ce..7a882efc4d18 100644 --- a/tests/ui/single_component_path_imports.fixed +++ b/tests/ui/single_component_path_imports.fixed @@ -1,8 +1,11 @@ // run-rustfix // compile-flags: --edition 2018 #![warn(clippy::single_component_path_imports)] +#![allow(unused_imports)] +use serde as edres; +pub use serde; fn main() { regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); diff --git a/tests/ui/single_component_path_imports.rs b/tests/ui/single_component_path_imports.rs index 3c4048a3b08e..d084425cd70f 100644 --- a/tests/ui/single_component_path_imports.rs +++ b/tests/ui/single_component_path_imports.rs @@ -1,9 +1,11 @@ // run-rustfix // compile-flags: --edition 2018 #![warn(clippy::single_component_path_imports)] +#![allow(unused_imports)] use regex; use serde as edres; +pub use serde; fn main() { regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); diff --git a/tests/ui/single_component_path_imports.stderr b/tests/ui/single_component_path_imports.stderr index 3f1cc28d581e..519ada0169a6 100644 --- a/tests/ui/single_component_path_imports.stderr +++ b/tests/ui/single_component_path_imports.stderr @@ -1,5 +1,5 @@ error: this import is redundant - --> $DIR/single_component_path_imports.rs:5:1 + --> $DIR/single_component_path_imports.rs:6:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely