]> 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 6614470681622c666c6edb9b23897e6247a4da50..197aa88cbbea39351214a4dd9642d29a482405ac 100644 (file)
@@ -5,14 +5,15 @@
     in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_then,
     without_block_comments,
 };
-use rustc::hir::*;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_lint, lint_array};
+use crate::rustc::hir::*;
+use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use crate::rustc::{declare_tool_lint, lint_array};
 use if_chain::if_chain;
-use rustc::ty::{self, TyCtxt};
+use crate::rustc::ty::{self, TyCtxt};
 use semver::Version;
-use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
-use syntax::source_map::Span;
+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,
+                                                    );
                                             },
                                         );
                                     }