@@ -64,14 +64,15 @@ impl Sysroot {
64
64
self . by_name ( "proc_macro" )
65
65
}
66
66
67
- pub fn crates < ' a > ( & ' a self ) -> impl Iterator < Item = SysrootCrate > + ExactSizeIterator + ' a {
67
+ pub fn crates ( & self ) -> impl Iterator < Item = SysrootCrate > + ExactSizeIterator + ' _ {
68
68
self . crates . iter ( ) . map ( |( id, _data) | id)
69
69
}
70
70
}
71
71
72
72
impl Sysroot {
73
+ /// Attempts to discover the toolchain's sysroot from the given `dir`.
73
74
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( ) ) ;
75
76
let sysroot_dir = discover_sysroot_dir ( dir, extra_env) ?;
76
77
let sysroot_src_dir =
77
78
discover_sysroot_src_dir_or_add_component ( & sysroot_dir, dir, extra_env) ?;
@@ -83,11 +84,10 @@ impl Sysroot {
83
84
cargo_toml : & ManifestPath ,
84
85
extra_env : & FxHashMap < String , String > ,
85
86
) -> Option < ManifestPath > {
86
- tracing:: debug!( "Discovering rustc source for {}" , cargo_toml. display( ) ) ;
87
+ tracing:: debug!( "discovering rustc source for {}" , cargo_toml. display( ) ) ;
87
88
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)
91
91
}
92
92
93
93
pub fn with_sysroot_dir ( sysroot_dir : AbsPathBuf ) -> Result < Sysroot > {
@@ -200,6 +200,7 @@ fn discover_sysroot_src_dir_or_add_component(
200
200
let mut rustup = Command :: new ( toolchain:: rustup ( ) ) ;
201
201
rustup. envs ( extra_env) ;
202
202
rustup. current_dir ( current_dir) . args ( & [ "component" , "add" , "rust-src" ] ) ;
203
+ tracing:: info!( "adding rust-src component by {:?}" , rustup) ;
203
204
utf8_stdout ( rustup) . ok ( ) ?;
204
205
get_rust_src ( sysroot_path)
205
206
} )
@@ -218,7 +219,7 @@ try installing the Rust source the same way you installed rustc",
218
219
fn get_rustc_src ( sysroot_path : & AbsPath ) -> Option < ManifestPath > {
219
220
let rustc_src = sysroot_path. join ( "lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" ) ;
220
221
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( ) ) ;
222
223
if fs:: metadata ( & rustc_src) . is_ok ( ) {
223
224
Some ( rustc_src)
224
225
} else {
@@ -228,7 +229,7 @@ fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
228
229
229
230
fn get_rust_src ( sysroot_path : & AbsPath ) -> Option < AbsPathBuf > {
230
231
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( ) ) ;
232
233
if fs:: metadata ( & rust_src) . is_ok ( ) {
233
234
Some ( rust_src)
234
235
} else {
0 commit comments