11use std:: cmp;
22
33use crate :: ich:: StableHashingContext ;
4- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
4+ use rustc_data_structures:: fx:: FxHashMap ;
55use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
66use rustc_errors:: { DiagnosticBuilder , DiagnosticId } ;
77use rustc_hir:: HirId ;
@@ -28,9 +28,6 @@ pub enum LintLevelSource {
2828 /// The provided `Level` is the level specified on the command line.
2929 /// (The actual level may be lower due to `--cap-lints`.)
3030 CommandLine ( Symbol , Level ) ,
31-
32- /// Lint is being forced to warn no matter what.
33- ForceWarn ( Symbol ) ,
3431}
3532
3633impl LintLevelSource {
@@ -39,7 +36,6 @@ impl LintLevelSource {
3936 LintLevelSource :: Default => symbol:: kw:: Default ,
4037 LintLevelSource :: Node ( name, _, _) => name,
4138 LintLevelSource :: CommandLine ( name, _) => name,
42- LintLevelSource :: ForceWarn ( name) => name,
4339 }
4440 }
4541
@@ -48,7 +44,6 @@ impl LintLevelSource {
4844 LintLevelSource :: Default => DUMMY_SP ,
4945 LintLevelSource :: Node ( _, span, _) => span,
5046 LintLevelSource :: CommandLine ( _, _) => DUMMY_SP ,
51- LintLevelSource :: ForceWarn ( _) => DUMMY_SP ,
5247 }
5348 }
5449}
@@ -60,7 +55,6 @@ pub type LevelAndSource = (Level, LintLevelSource);
6055pub struct LintLevelSets {
6156 pub list : Vec < LintSet > ,
6257 pub lint_cap : Level ,
63- pub force_warns : FxHashSet < LintId > ,
6458}
6559
6660#[ derive( Debug ) ]
@@ -79,11 +73,7 @@ pub enum LintSet {
7973
8074impl LintLevelSets {
8175 pub fn new ( ) -> Self {
82- LintLevelSets {
83- list : Vec :: new ( ) ,
84- lint_cap : Level :: Forbid ,
85- force_warns : FxHashSet :: default ( ) ,
86- }
76+ LintLevelSets { list : Vec :: new ( ) , lint_cap : Level :: Forbid }
8777 }
8878
8979 pub fn get_lint_level (
@@ -93,11 +83,6 @@ impl LintLevelSets {
9383 aux : Option < & FxHashMap < LintId , LevelAndSource > > ,
9484 sess : & Session ,
9585 ) -> LevelAndSource {
96- // Check whether we should always warn
97- if self . force_warns . contains ( & LintId :: of ( lint) ) {
98- return ( Level :: Warn , LintLevelSource :: ForceWarn ( Symbol :: intern ( lint. name ) ) ) ;
99- }
100-
10186 let ( level, mut src) = self . get_lint_id_level ( LintId :: of ( lint) , idx, aux) ;
10287
10388 // If `level` is none then we actually assume the default level for this
@@ -191,11 +176,11 @@ impl LintLevelMap {
191176impl < ' a > HashStable < StableHashingContext < ' a > > for LintLevelMap {
192177 #[ inline]
193178 fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
194- let LintLevelMap { ref sets, ref id_to_set, .. } = * self ;
179+ let LintLevelMap { ref sets, ref id_to_set } = * self ;
195180
196181 id_to_set. hash_stable ( hcx, hasher) ;
197182
198- let LintLevelSets { ref list, lint_cap, .. } = * sets;
183+ let LintLevelSets { ref list, lint_cap } = * sets;
199184
200185 lint_cap. hash_stable ( hcx, hasher) ;
201186
@@ -273,8 +258,8 @@ pub fn struct_lint_level<'s, 'd>(
273258 return ;
274259 }
275260 }
276- ( Level :: Warn , Some ( span) ) => sess. struct_span_warn ( span, "" ) ,
277- ( Level :: Warn , None ) => sess. struct_warn ( "" ) ,
261+ ( Level :: Warn | Level :: ForceWarn , Some ( span) ) => sess. struct_span_warn ( span, "" ) ,
262+ ( Level :: Warn | Level :: ForceWarn , None ) => sess. struct_warn ( "" ) ,
278263 ( Level :: Deny | Level :: Forbid , Some ( span) ) => sess. struct_span_err ( span, "" ) ,
279264 ( Level :: Deny | Level :: Forbid , None ) => sess. struct_err ( "" ) ,
280265 } ;
@@ -316,6 +301,7 @@ pub fn struct_lint_level<'s, 'd>(
316301 Level :: Deny => "-D" ,
317302 Level :: Forbid => "-F" ,
318303 Level :: Allow => "-A" ,
304+ Level :: ForceWarn => "--force-warns" ,
319305 } ;
320306 let hyphen_case_lint_name = name. replace ( "_" , "-" ) ;
321307 if lint_flag_val. as_str ( ) == name {
@@ -361,13 +347,6 @@ pub fn struct_lint_level<'s, 'd>(
361347 ) ;
362348 }
363349 }
364- LintLevelSource :: ForceWarn ( _) => {
365- sess. diag_note_once (
366- & mut err,
367- DiagnosticMessageId :: from ( lint) ,
368- "warning forced by `force-warns` commandline option" ,
369- ) ;
370- }
371350 }
372351
373352 err. code ( DiagnosticId :: Lint { name, has_future_breakage } ) ;
0 commit comments