]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/lint/levels.rs
Auto merge of #51956 - GuillaumeGomez:shutdown-doc-lints, r=oli-obk
[rust.git] / src / librustc / lint / levels.rs
index e8b536d52676382e356f723d64564451376c2e27..a1b84a7b716efdf4d4c9ea750bb34da9db858911 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::cmp;
 
-use errors::DiagnosticBuilder;
+use errors::{Applicability, DiagnosticBuilder};
 use hir::HirId;
 use ich::StableHashingContext;
 use lint::builtin;
@@ -22,6 +22,7 @@
 use syntax::ast;
 use syntax::attr;
 use syntax::codemap::MultiSpan;
+use syntax::feature_gate;
 use syntax::symbol::Symbol;
 use util::nodemap::FxHashMap;
 
@@ -118,6 +119,11 @@ fn get_lint_level(&self,
         // Ensure that we never exceed the `--cap-lints` argument.
         level = cmp::min(level, self.lint_cap);
 
+        if let Some(driver_level) = sess.driver_lint_caps.get(&LintId::of(lint)) {
+            // Ensure that we never exceed driver level.
+            level = cmp::min(*driver_level, level);
+        }
+
         return (level, src)
     }
 
@@ -198,7 +204,7 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush {
                       "malformed lint attribute");
         };
         for attr in attrs {
-            let level = match attr.name().and_then(|name| Level::from_str(&name.as_str())) {
+            let level = match Level::from_str(&attr.name().as_str()) {
                 None => continue,
                 Some(lvl) => lvl,
             };
@@ -221,7 +227,29 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush {
                         continue
                     }
                 };
-                let name = word.ident.name;
+                if let Some(lint_tool) = word.is_scoped() {
+                    if !self.sess.features_untracked().tool_lints {
+                        feature_gate::emit_feature_err(&sess.parse_sess,
+                                                       "tool_lints",
+                                                       word.span,
+                                                       feature_gate::GateIssue::Language,
+                                                       &format!("scoped lint `{}` is experimental",
+                                                                word.ident));
+                    }
+
+                    if !attr::is_known_lint_tool(lint_tool) {
+                        span_err!(
+                            sess,
+                            lint_tool.span,
+                            E0710,
+                            "an unknown tool name found in scoped lint: `{}`",
+                            word.ident
+                        );
+                    }
+
+                    continue
+                }
+                let name = word.name();
                 match store.check_lint_name(&name.as_str()) {
                     CheckLintNameResult::Ok(ids) => {
                         let src = LintSource::Node(name, li.span);
@@ -260,15 +288,16 @@ pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush {
                                                 Some(li.span.into()),
                                                 &msg);
                         if name.as_str().chars().any(|c| c.is_uppercase()) {
-                            let name_lower = name.as_str().to_lowercase();
+                            let name_lower = name.as_str().to_lowercase().to_string();
                             if let CheckLintNameResult::NoLint =
                                     store.check_lint_name(&name_lower) {
                                 db.emit();
                             } else {
-                                db.span_suggestion(
+                                db.span_suggestion_with_applicability(
                                     li.span,
                                     "lowercase the lint name",
-                                    name_lower
+                                    name_lower,
+                                    Applicability::MachineApplicable
                                 ).emit();
                             }
                         } else {