33//! This module implements parsing `bootstrap.toml` configuration files to tweak
44//! how the build runs.
55
6- use std:: cell:: { Cell , RefCell } ;
6+ use std:: cell:: Cell ;
77use std:: collections:: { BTreeSet , HashMap , HashSet } ;
88use std:: fmt:: { self , Display } ;
99use std:: hash:: Hash ;
@@ -406,11 +406,7 @@ pub struct Config {
406406 pub initial_rustc : PathBuf ,
407407 pub initial_cargo_clippy : Option < PathBuf > ,
408408 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 > ,
414410
415411 /// The paths to work with. For example: with `./x check foo bar` we get
416412 /// `paths=["foo", "bar"]`.
@@ -428,15 +424,6 @@ pub struct Config {
428424 pub path_modification_cache : Arc < Mutex < HashMap < Vec < & ' static str > , PathFreshness > > > ,
429425}
430426
431- #[ derive( Clone , Debug , Default ) ]
432- pub enum RustfmtState {
433- SystemToolchain ( PathBuf ) ,
434- Downloaded ( PathBuf ) ,
435- Unavailable ,
436- #[ default]
437- LazyEvaluated ,
438- }
439-
440427#[ derive( Debug , Default , Clone , Copy , PartialEq , Eq ) ]
441428pub enum LlvmLibunwind {
442429 #[ default]
@@ -2448,13 +2435,8 @@ impl Config {
24482435 } ) ;
24492436 }
24502437
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 ( ) } ;
24582440
24592441 // Now that we've reached the end of our configuration, infer the
24602442 // default values for all options that we haven't otherwise stored yet.
@@ -2851,25 +2833,6 @@ impl Config {
28512833 . as_deref ( )
28522834 }
28532835
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-
28732836 /// Runs a function if verbosity is greater than 0
28742837 pub fn verbose ( & self , f : impl Fn ( ) ) {
28752838 if self . is_verbose ( ) {
0 commit comments