]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/attrs.rs
Use span_suggestion_with_applicability instead of span_suggestion
[rust.git] / clippy_lints / src / attrs.rs
index 3a8514818f6fd05a4c8fc42be21362a8e1a0fe16..197aa88cbbea39351214a4dd9642d29a482405ac 100644 (file)
@@ -13,6 +13,7 @@
 use semver::Version;
 use crate::syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
 use crate::syntax::source_map::Span;
+use crate::rustc_errors::Applicability;
 
 /// **What it does:** Checks for items annotated with `#[inline(always)]`,
 /// unless the annotated function is empty or simply panics.
@@ -180,10 +181,15 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
                                                                 || is_word(lint, "deprecated") {
                                                 return
                                         },
-                                        ItemKind::ExternCrate(..) => if is_word(lint, "unused_imports")
-                                                                        && skip_unused_imports {
+                                        ItemKind::ExternCrate(..) => {
+                                            if is_word(lint, "unused_imports")
+                                                && skip_unused_imports {
+                                                    return
+                                            }
+                                            if is_word(lint, "unused_extern_crates") {
                                                 return
-                                        },
+                                            }
+                                        }
                                         _ => {},
                                     }
                                 }
@@ -198,7 +204,12 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
                                             "useless lint attribute",
                                             |db| {
                                                 sugg = sugg.replacen("#[", "#![", 1);
-                                                db.span_suggestion(line_span, "if you just forgot a `!`, use", sugg);
+                                                db.span_suggestion_with_applicability(
+                                                    line_span,
+                                                    "if you just forgot a `!`, use",
+                                                    sugg,
+                                                    Applicability::Unspecified,
+                                                    );
                                             },
                                         );
                                     }