3
3
//! This module implements parsing `bootstrap.toml` configuration files to tweak
4
4
//! how the build runs.
5
5
6
- use std:: cell:: { Cell , RefCell } ;
6
+ use std:: cell:: Cell ;
7
7
use std:: collections:: { BTreeSet , HashMap , HashSet } ;
8
8
use std:: fmt:: { self , Display } ;
9
9
use std:: hash:: Hash ;
@@ -406,11 +406,7 @@ pub struct Config {
406
406
pub initial_rustc : PathBuf ,
407
407
pub initial_cargo_clippy : Option < PathBuf > ,
408
408
pub initial_sysroot : PathBuf ,
409
-
410
- #[ cfg( not( test) ) ]
411
- initial_rustfmt : RefCell < RustfmtState > ,
412
- #[ cfg( test) ]
413
- pub initial_rustfmt : RefCell < RustfmtState > ,
409
+ pub initial_rustfmt : Option < PathBuf > ,
414
410
415
411
/// The paths to work with. For example: with `./x check foo bar` we get
416
412
/// `paths=["foo", "bar"]`.
@@ -428,15 +424,6 @@ pub struct Config {
428
424
pub path_modification_cache : Arc < Mutex < HashMap < Vec < & ' static str > , PathFreshness > > > ,
429
425
}
430
426
431
- #[ derive( Clone , Debug , Default ) ]
432
- pub enum RustfmtState {
433
- SystemToolchain ( PathBuf ) ,
434
- Downloaded ( PathBuf ) ,
435
- Unavailable ,
436
- #[ default]
437
- LazyEvaluated ,
438
- }
439
-
440
427
#[ derive( Debug , Default , Clone , Copy , PartialEq , Eq ) ]
441
428
pub enum LlvmLibunwind {
442
429
#[ default]
@@ -2448,13 +2435,8 @@ impl Config {
2448
2435
} ) ;
2449
2436
}
2450
2437
2451
- if let Some ( r) = rustfmt {
2452
- * config. initial_rustfmt . borrow_mut ( ) = if r. exists ( ) {
2453
- RustfmtState :: SystemToolchain ( r)
2454
- } else {
2455
- RustfmtState :: Unavailable
2456
- } ;
2457
- }
2438
+ config. initial_rustfmt =
2439
+ if let Some ( r) = rustfmt { Some ( r) } else { config. maybe_download_rustfmt ( ) } ;
2458
2440
2459
2441
// Now that we've reached the end of our configuration, infer the
2460
2442
// default values for all options that we haven't otherwise stored yet.
@@ -2851,25 +2833,6 @@ impl Config {
2851
2833
. as_deref ( )
2852
2834
}
2853
2835
2854
- pub ( crate ) fn initial_rustfmt ( & self ) -> Option < PathBuf > {
2855
- match & mut * self . initial_rustfmt . borrow_mut ( ) {
2856
- RustfmtState :: SystemToolchain ( p) | RustfmtState :: Downloaded ( p) => Some ( p. clone ( ) ) ,
2857
- RustfmtState :: Unavailable => None ,
2858
- r @ RustfmtState :: LazyEvaluated => {
2859
- if self . dry_run ( ) {
2860
- return Some ( PathBuf :: new ( ) ) ;
2861
- }
2862
- let path = self . maybe_download_rustfmt ( ) ;
2863
- * r = if let Some ( p) = & path {
2864
- RustfmtState :: Downloaded ( p. clone ( ) )
2865
- } else {
2866
- RustfmtState :: Unavailable
2867
- } ;
2868
- path
2869
- }
2870
- }
2871
- }
2872
-
2873
2836
/// Runs a function if verbosity is greater than 0
2874
2837
pub fn verbose ( & self , f : impl Fn ( ) ) {
2875
2838
if self . is_verbose ( ) {
0 commit comments