File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -157,18 +157,19 @@ fn add_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
157157 let path = "clippy_lints/src/lib.rs" ;
158158 let mut lib_rs = fs:: read_to_string ( path) . context ( "reading" ) ?;
159159
160- let comment_start = lib_rs. find ( "// add lints here," ) . expect ( "Couldn't find comment" ) ;
161- let ctor_arg = if lint. pass == Pass :: Late { "_" } else { "" } ;
162- let lint_pass = lint. pass ;
160+ let ( comment, ctor_arg) = if lint. pass == Pass :: Late {
161+ ( "// add late passes here" , "_" )
162+ } else {
163+ ( "// add early passes here" , "" )
164+ } ;
165+ let comment_start = lib_rs. find ( comment) . expect ( "Couldn't find comment" ) ;
163166 let module_name = lint. name ;
164167 let camel_name = to_camel_case ( lint. name ) ;
165168
166169 let new_lint = if enable_msrv {
167- format ! (
168- "store.register_{lint_pass}_pass(move |{ctor_arg}| Box::new({module_name}::{camel_name}::new(conf)));\n " ,
169- )
170+ format ! ( "Box::new(move |{ctor_arg}| Box::new({module_name}::{camel_name}::new(conf))),\n " , )
170171 } else {
171- format ! ( "store.register_{lint_pass}_pass (|{ctor_arg}| Box::new({module_name}::{camel_name})); \n " , )
172+ format ! ( "Box::new (|{ctor_arg}| Box::new({module_name}::{camel_name})), \n " , )
172173 } ;
173174
174175 lib_rs. insert_str ( comment_start, & new_lint) ;
Original file line number Diff line number Diff line change @@ -511,6 +511,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
511511 Box :: new ( || Box :: new ( byte_char_slices:: ByteCharSlice ) ) ,
512512 Box :: new ( || Box :: new ( cfg_not_test:: CfgNotTest ) ) ,
513513 Box :: new ( || Box :: new ( empty_line_after:: EmptyLineAfter :: new ( ) ) ) ,
514+ // add early passes here, used by `cargo dev new_lint`
514515 ] ;
515516 store. early_passes . extend ( early_lints) ;
516517
@@ -847,7 +848,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
847848 Box :: new ( |_| Box :: new ( toplevel_ref_arg:: ToplevelRefArg ) ) ,
848849 Box :: new ( |_| Box :: new ( volatile_composites:: VolatileComposites ) ) ,
849850 Box :: new ( |_| Box :: new ( replace_box:: ReplaceBox ) ) ,
851+ // add late passes here, used by `cargo dev new_lint`
850852 ] ;
851853 store. late_passes . extend ( late_lints) ;
852- // add lints here, do not remove this comment, it's used in `new_lint`
853854}
You can’t perform that action at this time.
0 commit comments