@@ -106,12 +106,12 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions<'_>) -> CargoResult<()> {
106
106
eprintln ! ( "Warning: clippy-driver not found: {:?}" , e) ;
107
107
}
108
108
109
- opts. compile_opts . build_config . primary_unit_rustc = Some ( util:: config:: clippy_driver ( ) ) ;
109
+ let clippy_args = opts
110
+ . clippy_args
111
+ . as_ref ( )
112
+ . map_or_else ( String :: new, |args| serde_json:: to_string ( & args) . unwrap ( ) ) ;
110
113
111
- if let Some ( clippy_args) = & opts. clippy_args {
112
- let clippy_args = serde_json:: to_string ( & clippy_args) . unwrap ( ) ;
113
- wrapper. env ( CLIPPY_FIX_ARGS , clippy_args) ;
114
- }
114
+ wrapper. env ( CLIPPY_FIX_ARGS , clippy_args) ;
115
115
}
116
116
117
117
* opts
@@ -130,7 +130,9 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions<'_>) -> CargoResult<()> {
130
130
server. configure ( & mut wrapper) ;
131
131
}
132
132
133
- opts. compile_opts . build_config . rustc_wrapper = Some ( wrapper) ;
133
+ // primary crates are compiled using a cargo subprocess to do extra work of applying fixes and
134
+ // repeating build until there are no more changes to be applied
135
+ opts. compile_opts . build_config . primary_unit_rustc = Some ( wrapper) ;
134
136
135
137
ops:: compile ( ws, & opts. compile_opts ) ?;
136
138
Ok ( ( ) )
@@ -219,18 +221,10 @@ pub fn fix_maybe_exec_rustc() -> CargoResult<bool> {
219
221
trace ! ( "cargo-fix as rustc got file {:?}" , args. file) ;
220
222
let rustc = args. rustc . as_ref ( ) . expect ( "fix wrapper rustc was not set" ) ;
221
223
222
- // Our goal is to fix only the crates that the end user is interested in.
223
- // That's very likely to only mean the crates in the workspace the user is
224
- // working on, not random crates.io crates.
225
- //
226
- // The master cargo process tells us whether or not this is a "primary"
227
- // crate via the CARGO_PRIMARY_PACKAGE environment variable.
228
224
let mut fixes = FixedCrate :: default ( ) ;
229
225
if let Some ( path) = & args. file {
230
- if args. primary_package {
231
- trace ! ( "start rustfixing {:?}" , path) ;
232
- fixes = rustfix_crate ( & lock_addr, rustc. as_ref ( ) , path, & args) ?;
233
- }
226
+ trace ! ( "start rustfixing {:?}" , path) ;
227
+ fixes = rustfix_crate ( & lock_addr, rustc. as_ref ( ) , path, & args) ?;
234
228
}
235
229
236
230
// Ok now we have our final goal of testing out the changes that we applied.
@@ -279,7 +273,6 @@ pub fn fix_maybe_exec_rustc() -> CargoResult<bool> {
279
273
}
280
274
281
275
// This final fall-through handles multiple cases;
282
- // - Non-primary crates, which need to be built.
283
276
// - If the fix failed, show the original warnings and suggestions.
284
277
// - If `--broken-code`, show the error messages.
285
278
// - If the fix succeeded, show any remaining warnings.
@@ -589,7 +582,6 @@ struct FixArgs {
589
582
idioms : bool ,
590
583
enabled_edition : Option < String > ,
591
584
other : Vec < OsString > ,
592
- primary_package : bool ,
593
585
rustc : Option < PathBuf > ,
594
586
clippy_args : Vec < String > ,
595
587
}
@@ -609,10 +601,12 @@ impl Default for PrepareFor {
609
601
impl FixArgs {
610
602
fn get ( ) -> FixArgs {
611
603
let mut ret = FixArgs :: default ( ) ;
612
- ret. rustc = env:: args_os ( ) . nth ( 1 ) . map ( PathBuf :: from) ;
613
604
614
605
if let Ok ( clippy_args) = env:: var ( CLIPPY_FIX_ARGS ) {
615
606
ret. clippy_args = serde_json:: from_str ( & clippy_args) . unwrap ( ) ;
607
+ ret. rustc = Some ( util:: config:: clippy_driver ( ) ) ;
608
+ } else {
609
+ ret. rustc = env:: args_os ( ) . nth ( 1 ) . map ( PathBuf :: from) ;
616
610
}
617
611
618
612
for arg in env:: args_os ( ) . skip ( 2 ) {
@@ -642,7 +636,6 @@ impl FixArgs {
642
636
}
643
637
644
638
ret. idioms = env:: var ( IDIOMS_ENV ) . is_ok ( ) ;
645
- ret. primary_package = env:: var ( "CARGO_PRIMARY_PACKAGE" ) . is_ok ( ) ;
646
639
ret
647
640
}
648
641
@@ -658,14 +651,13 @@ impl FixArgs {
658
651
cmd. args ( & self . other ) . arg ( "--cap-lints=warn" ) ;
659
652
if let Some ( edition) = & self . enabled_edition {
660
653
cmd. arg ( "--edition" ) . arg ( edition) ;
661
- if self . idioms && self . primary_package && edition == "2018" {
654
+ if self . idioms && edition == "2018" {
662
655
cmd. arg ( "-Wrust-2018-idioms" ) ;
663
656
}
664
657
}
665
- if self . primary_package {
666
- if let Some ( edition) = self . prepare_for_edition_resolve ( ) {
667
- cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
668
- }
658
+
659
+ if let Some ( edition) = self . prepare_for_edition_resolve ( ) {
660
+ cmd. arg ( "-W" ) . arg ( format ! ( "rust-{}-compatibility" , edition) ) ;
669
661
}
670
662
}
671
663
0 commit comments