about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-06-04 23:21:43 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2021-06-26 12:41:19 +0200
commite42271db0d8ee14f0599e7b72625bb2f133f5cac (patch)
tree6f1dce2248057ca3f3f2107fa93cc1364f94b172 /compiler/rustc_middle/src
parent6830052c7b87217886324129bffbe096e485d415 (diff)
downloadrust-e42271db0d8ee14f0599e7b72625bb2f133f5cac.tar.gz
rust-e42271db0d8ee14f0599e7b72625bb2f133f5cac.zip
Make ForceWarn a lint level.
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/lint.rs35
1 files changed, 7 insertions, 28 deletions
diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs
index 8180d853f60..69d0f53230c 100644
--- a/compiler/rustc_middle/src/lint.rs
+++ b/compiler/rustc_middle/src/lint.rs
@@ -1,7 +1,7 @@
 use std::cmp;
 
 use crate::ich::StableHashingContext;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_errors::{DiagnosticBuilder, DiagnosticId};
 use rustc_hir::HirId;
@@ -28,9 +28,6 @@ pub enum LintLevelSource {
     /// The provided `Level` is the level specified on the command line.
     /// (The actual level may be lower due to `--cap-lints`.)
     CommandLine(Symbol, Level),
-
-    /// Lint is being forced to warn no matter what.
-    ForceWarn(Symbol),
 }
 
 impl LintLevelSource {
@@ -39,7 +36,6 @@ impl LintLevelSource {
             LintLevelSource::Default => symbol::kw::Default,
             LintLevelSource::Node(name, _, _) => name,
             LintLevelSource::CommandLine(name, _) => name,
-            LintLevelSource::ForceWarn(name) => name,
         }
     }
 
@@ -48,7 +44,6 @@ impl LintLevelSource {
             LintLevelSource::Default => DUMMY_SP,
             LintLevelSource::Node(_, span, _) => span,
             LintLevelSource::CommandLine(_, _) => DUMMY_SP,
-            LintLevelSource::ForceWarn(_) => DUMMY_SP,
         }
     }
 }
@@ -60,7 +55,6 @@ pub type LevelAndSource = (Level, LintLevelSource);
 pub struct LintLevelSets {
     pub list: Vec<LintSet>,
     pub lint_cap: Level,
-    pub force_warns: FxHashSet<LintId>,
 }
 
 #[derive(Debug)]
@@ -79,11 +73,7 @@ pub enum LintSet {
 
 impl LintLevelSets {
     pub fn new() -> Self {
-        LintLevelSets {
-            list: Vec::new(),
-            lint_cap: Level::Forbid,
-            force_warns: FxHashSet::default(),
-        }
+        LintLevelSets { list: Vec::new(), lint_cap: Level::Forbid }
     }
 
     pub fn get_lint_level(
@@ -93,11 +83,6 @@ impl LintLevelSets {
         aux: Option<&FxHashMap<LintId, LevelAndSource>>,
         sess: &Session,
     ) -> LevelAndSource {
-        // Check whether we should always warn
-        if self.force_warns.contains(&LintId::of(lint)) {
-            return (Level::Warn, LintLevelSource::ForceWarn(Symbol::intern(lint.name)));
-        }
-
         let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux);
 
         // If `level` is none then we actually assume the default level for this
@@ -191,11 +176,11 @@ impl LintLevelMap {
 impl<'a> HashStable<StableHashingContext<'a>> for LintLevelMap {
     #[inline]
     fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
-        let LintLevelMap { ref sets, ref id_to_set, .. } = *self;
+        let LintLevelMap { ref sets, ref id_to_set } = *self;
 
         id_to_set.hash_stable(hcx, hasher);
 
-        let LintLevelSets { ref list, lint_cap, .. } = *sets;
+        let LintLevelSets { ref list, lint_cap } = *sets;
 
         lint_cap.hash_stable(hcx, hasher);
 
@@ -273,8 +258,8 @@ pub fn struct_lint_level<'s, 'd>(
                     return;
                 }
             }
-            (Level::Warn, Some(span)) => sess.struct_span_warn(span, ""),
-            (Level::Warn, None) => sess.struct_warn(""),
+            (Level::Warn | Level::ForceWarn, Some(span)) => sess.struct_span_warn(span, ""),
+            (Level::Warn | Level::ForceWarn, None) => sess.struct_warn(""),
             (Level::Deny | Level::Forbid, Some(span)) => sess.struct_span_err(span, ""),
             (Level::Deny | Level::Forbid, None) => sess.struct_err(""),
         };
@@ -316,6 +301,7 @@ pub fn struct_lint_level<'s, 'd>(
                     Level::Deny => "-D",
                     Level::Forbid => "-F",
                     Level::Allow => "-A",
+                    Level::ForceWarn => "--force-warns",
                 };
                 let hyphen_case_lint_name = name.replace("_", "-");
                 if lint_flag_val.as_str() == name {
@@ -361,13 +347,6 @@ pub fn struct_lint_level<'s, 'd>(
                     );
                 }
             }
-            LintLevelSource::ForceWarn(_) => {
-                sess.diag_note_once(
-                    &mut err,
-                    DiagnosticMessageId::from(lint),
-                    "warning forced by `force-warns` commandline option",
-                );
-            }
         }
 
         err.code(DiagnosticId::Lint { name, has_future_breakage });