@@ -64,14 +64,15 @@ impl Sysroot {
6464 self . by_name ( "proc_macro" )
6565 }
6666
67- pub fn crates < ' a > ( & ' a self ) -> impl Iterator < Item = SysrootCrate > + ExactSizeIterator + ' a {
67+ pub fn crates ( & self ) -> impl Iterator < Item = SysrootCrate > + ExactSizeIterator + ' _ {
6868 self . crates . iter ( ) . map ( |( id, _data) | id)
6969 }
7070}
7171
7272impl Sysroot {
73+ /// Attempts to discover the toolchain's sysroot from the given `dir`.
7374 pub fn discover ( dir : & AbsPath , extra_env : & FxHashMap < String , String > ) -> Result < Sysroot > {
74- tracing:: debug!( "Discovering sysroot for {}" , dir. display( ) ) ;
75+ tracing:: debug!( "discovering sysroot for {}" , dir. display( ) ) ;
7576 let sysroot_dir = discover_sysroot_dir ( dir, extra_env) ?;
7677 let sysroot_src_dir =
7778 discover_sysroot_src_dir_or_add_component ( & sysroot_dir, dir, extra_env) ?;
@@ -83,11 +84,10 @@ impl Sysroot {
8384 cargo_toml : & ManifestPath ,
8485 extra_env : & FxHashMap < String , String > ,
8586 ) -> Option < ManifestPath > {
86- tracing:: debug!( "Discovering rustc source for {}" , cargo_toml. display( ) ) ;
87+ tracing:: debug!( "discovering rustc source for {}" , cargo_toml. display( ) ) ;
8788 let current_dir = cargo_toml. parent ( ) ;
88- discover_sysroot_dir ( current_dir, extra_env)
89- . ok ( )
90- . and_then ( |sysroot_dir| get_rustc_src ( & sysroot_dir) )
89+ let sysroot_dir = discover_sysroot_dir ( current_dir, extra_env) . ok ( ) ?;
90+ get_rustc_src ( & sysroot_dir)
9191 }
9292
9393 pub fn with_sysroot_dir ( sysroot_dir : AbsPathBuf ) -> Result < Sysroot > {
@@ -200,6 +200,7 @@ fn discover_sysroot_src_dir_or_add_component(
200200 let mut rustup = Command :: new ( toolchain:: rustup ( ) ) ;
201201 rustup. envs ( extra_env) ;
202202 rustup. current_dir ( current_dir) . args ( & [ "component" , "add" , "rust-src" ] ) ;
203+ tracing:: info!( "adding rust-src component by {:?}" , rustup) ;
203204 utf8_stdout ( rustup) . ok ( ) ?;
204205 get_rust_src ( sysroot_path)
205206 } )
@@ -218,7 +219,7 @@ try installing the Rust source the same way you installed rustc",
218219fn get_rustc_src ( sysroot_path : & AbsPath ) -> Option < ManifestPath > {
219220 let rustc_src = sysroot_path. join ( "lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" ) ;
220221 let rustc_src = ManifestPath :: try_from ( rustc_src) . ok ( ) ?;
221- tracing:: debug!( "Checking for rustc source code: {}" , rustc_src. display( ) ) ;
222+ tracing:: debug!( "checking for rustc source code: {}" , rustc_src. display( ) ) ;
222223 if fs:: metadata ( & rustc_src) . is_ok ( ) {
223224 Some ( rustc_src)
224225 } else {
@@ -228,7 +229,7 @@ fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
228229
229230fn get_rust_src ( sysroot_path : & AbsPath ) -> Option < AbsPathBuf > {
230231 let rust_src = sysroot_path. join ( "lib/rustlib/src/rust/library" ) ;
231- tracing:: debug!( "Checking sysroot: {}" , rust_src. display( ) ) ;
232+ tracing:: debug!( "checking sysroot library : {}" , rust_src. display( ) ) ;
232233 if fs:: metadata ( & rust_src) . is_ok ( ) {
233234 Some ( rust_src)
234235 } else {
0 commit comments