@@ -10,7 +10,6 @@ use rustc_hir as hir;
1010use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
1111use rustc_hir:: { intravisit, HirId } ;
1212use rustc_middle:: hir:: map:: Map ;
13- use rustc_middle:: lint:: LevelSource ;
1413use rustc_middle:: lint:: LintDiagnosticBuilder ;
1514use rustc_middle:: lint:: { struct_lint_level, LintLevelMap , LintLevelSets , LintSet , LintSource } ;
1615use rustc_middle:: ty:: query:: Providers ;
@@ -97,44 +96,6 @@ impl<'s> LintLevelsBuilder<'s> {
9796 self . sets . list . push ( LintSet :: CommandLine { specs } ) ;
9897 }
9998
100- /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
101- /// (e.g. if a forbid was already inserted on the same scope), then emits a
102- /// diagnostic with no change to `specs`.
103- fn insert_spec (
104- & mut self ,
105- specs : & mut FxHashMap < LintId , LevelSource > ,
106- id : LintId ,
107- ( level, src) : LevelSource ,
108- ) {
109- if let Some ( ( old_level, old_src) ) = specs. get ( & id) {
110- if old_level == & Level :: Forbid && level != Level :: Forbid {
111- let mut diag_builder = struct_span_err ! (
112- self . sess,
113- src. span( ) ,
114- E0453 ,
115- "{}({}) incompatible with previous forbid in same scope" ,
116- level. as_str( ) ,
117- src. name( ) ,
118- ) ;
119- match * old_src {
120- LintSource :: Default => { }
121- LintSource :: Node ( _, forbid_source_span, reason) => {
122- diag_builder. span_label ( forbid_source_span, "`forbid` level set here" ) ;
123- if let Some ( rationale) = reason {
124- diag_builder. note ( & rationale. as_str ( ) ) ;
125- }
126- }
127- LintSource :: CommandLine ( _, _) => {
128- diag_builder. note ( "`forbid` lint level was set on command line" ) ;
129- }
130- }
131- diag_builder. emit ( ) ;
132- return ;
133- }
134- }
135- specs. insert ( id, ( level, src) ) ;
136- }
137-
13899 /// Pushes a list of AST lint attributes onto this context.
139100 ///
140101 /// This function will return a `BuilderPush` object which should be passed
@@ -149,7 +110,7 @@ impl<'s> LintLevelsBuilder<'s> {
149110 /// `#[allow]`
150111 ///
151112 /// Don't forget to call `pop`!
152- pub ( crate ) fn push (
113+ pub fn push (
153114 & mut self ,
154115 attrs : & [ ast:: Attribute ] ,
155116 store : & LintStore ,
@@ -261,7 +222,7 @@ impl<'s> LintLevelsBuilder<'s> {
261222 let src = LintSource :: Node ( name, li. span ( ) , reason) ;
262223 for & id in ids {
263224 self . check_gated_lint ( id, attr. span ) ;
264- self . insert_spec ( & mut specs , id, ( level, src) ) ;
225+ specs . insert ( id, ( level, src) ) ;
265226 }
266227 }
267228
@@ -275,7 +236,7 @@ impl<'s> LintLevelsBuilder<'s> {
275236 reason,
276237 ) ;
277238 for id in ids {
278- self . insert_spec ( & mut specs , * id, ( level, src) ) ;
239+ specs . insert ( * id, ( level, src) ) ;
279240 }
280241 }
281242 Err ( ( Some ( ids) , new_lint_name) ) => {
@@ -312,7 +273,7 @@ impl<'s> LintLevelsBuilder<'s> {
312273 reason,
313274 ) ;
314275 for id in ids {
315- self . insert_spec ( & mut specs , * id, ( level, src) ) ;
276+ specs . insert ( * id, ( level, src) ) ;
316277 }
317278 }
318279 Err ( ( None , _) ) => {
0 commit comments