@@ -37,44 +37,8 @@ enum LintSet {
3737}
3838
3939impl LintLevelSets {
40- pub fn new ( sess : & Session , lint_store : & LintStore ) -> LintLevelSets {
41- let mut me = LintLevelSets { list : Vec :: new ( ) , lint_cap : Level :: Forbid } ;
42- me. process_command_line ( sess, lint_store) ;
43- return me;
44- }
45-
46- pub fn builder < ' a > (
47- sess : & ' a Session ,
48- warn_about_weird_lints : bool ,
49- store : & LintStore ,
50- ) -> LintLevelsBuilder < ' a > {
51- LintLevelsBuilder :: new ( sess, warn_about_weird_lints, LintLevelSets :: new ( sess, store) )
52- }
53-
54- fn process_command_line ( & mut self , sess : & Session , store : & LintStore ) {
55- let mut specs = FxHashMap :: default ( ) ;
56- self . lint_cap = sess. opts . lint_cap . unwrap_or ( Level :: Forbid ) ;
57-
58- for & ( ref lint_name, level) in & sess. opts . lint_opts {
59- store. check_lint_name_cmdline ( sess, & lint_name, level) ;
60-
61- // If the cap is less than this specified level, e.g., if we've got
62- // `--cap-lints allow` but we've also got `-D foo` then we ignore
63- // this specification as the lint cap will set it to allow anyway.
64- let level = cmp:: min ( level, self . lint_cap ) ;
65-
66- let lint_flag_val = Symbol :: intern ( lint_name) ;
67- let ids = match store. find_lints ( & lint_name) {
68- Ok ( ids) => ids,
69- Err ( _) => continue , // errors handled in check_lint_name_cmdline above
70- } ;
71- for id in ids {
72- let src = LintSource :: CommandLine ( lint_flag_val) ;
73- specs. insert ( id, ( level, src) ) ;
74- }
75- }
76-
77- self . list . push ( LintSet :: CommandLine { specs : specs } ) ;
40+ fn new ( ) -> Self {
41+ LintLevelSets { list : Vec :: new ( ) , lint_cap : Level :: Forbid }
7842 }
7943
8044 fn get_lint_level (
@@ -159,19 +123,43 @@ pub struct BuilderPush {
159123}
160124
161125impl < ' a > LintLevelsBuilder < ' a > {
162- pub fn new (
163- sess : & ' a Session ,
164- warn_about_weird_lints : bool ,
165- sets : LintLevelSets ,
166- ) -> LintLevelsBuilder < ' a > {
167- assert_eq ! ( sets. list. len( ) , 1 ) ;
168- LintLevelsBuilder {
126+ pub fn new ( sess : & ' a Session , warn_about_weird_lints : bool , store : & LintStore ) -> Self {
127+ let mut builder = LintLevelsBuilder {
169128 sess,
170- sets,
129+ sets : LintLevelSets :: new ( ) ,
171130 cur : 0 ,
172131 id_to_set : Default :: default ( ) ,
173132 warn_about_weird_lints,
133+ } ;
134+ builder. process_command_line ( sess, store) ;
135+ assert_eq ! ( builder. sets. list. len( ) , 1 ) ;
136+ builder
137+ }
138+
139+ fn process_command_line ( & mut self , sess : & Session , store : & LintStore ) {
140+ let mut specs = FxHashMap :: default ( ) ;
141+ self . sets . lint_cap = sess. opts . lint_cap . unwrap_or ( Level :: Forbid ) ;
142+
143+ for & ( ref lint_name, level) in & sess. opts . lint_opts {
144+ store. check_lint_name_cmdline ( sess, & lint_name, level) ;
145+
146+ // If the cap is less than this specified level, e.g., if we've got
147+ // `--cap-lints allow` but we've also got `-D foo` then we ignore
148+ // this specification as the lint cap will set it to allow anyway.
149+ let level = cmp:: min ( level, self . sets . lint_cap ) ;
150+
151+ let lint_flag_val = Symbol :: intern ( lint_name) ;
152+ let ids = match store. find_lints ( & lint_name) {
153+ Ok ( ids) => ids,
154+ Err ( _) => continue , // errors handled in check_lint_name_cmdline above
155+ } ;
156+ for id in ids {
157+ let src = LintSource :: CommandLine ( lint_flag_val) ;
158+ specs. insert ( id, ( level, src) ) ;
159+ }
174160 }
161+
162+ self . sets . list . push ( LintSet :: CommandLine { specs } ) ;
175163 }
176164
177165 /// Pushes a list of AST lint attributes onto this context.
0 commit comments