@@ -301,34 +301,19 @@ fn setup(ask_user: bool) {
301
301
. stdout ;
302
302
let sysroot = std:: str:: from_utf8 ( & sysroot) . unwrap ( ) ;
303
303
let sysroot = Path :: new ( sysroot. trim_end_matches ( '\n' ) ) ;
304
- // First try: `$SYSROOT/lib/rustlib/src/rust`; test if that contains `Cargo.lock`.
305
- let rustup_src = sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( "src" ) . join ( "rust" ) ;
306
- let base_dir = if rustup_src. join ( "Cargo.lock" ) . exists ( ) {
307
- // Just use this.
308
- rustup_src
309
- } else {
310
- // Maybe this is a local toolchain built with `x.py` and linked into `rustup`?
311
- // Second try: `$SYSROOT/../../..`; test if that contains `x.py`.
312
- let local_src = sysroot. parent ( ) . and_then ( Path :: parent) . and_then ( Path :: parent) ;
313
- match local_src {
314
- Some ( local_src) if local_src. join ( "x.py" ) . exists ( ) => {
315
- // Use this.
316
- PathBuf :: from ( local_src)
317
- }
318
- _ => {
319
- // Fallback: Ask the user to install the `rust-src` component, and use that.
320
- let mut cmd = Command :: new ( "rustup" ) ;
321
- cmd. args ( & [ "component" , "add" , "rust-src" ] ) ;
322
- ask_to_run (
323
- cmd,
324
- ask_user,
325
- "install the rustc-src component for the selected toolchain" ,
326
- ) ;
327
- rustup_src
328
- }
329
- }
330
- } ;
331
- base_dir. join ( "src" ) // Xargo wants the src-subdir
304
+ // Check for `$SYSROOT/lib/rustlib/src/rust/src`; test if that contains `libstd/lib.rs`.
305
+ let rustup_src = sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( "src" ) . join ( "rust" ) . join ( "src" ) ;
306
+ if !rustup_src. join ( "libstd" ) . join ( "lib.rs" ) . exists ( ) {
307
+ // Ask the user to install the `rust-src` component, and use that.
308
+ let mut cmd = Command :: new ( "rustup" ) ;
309
+ cmd. args ( & [ "component" , "add" , "rust-src" ] ) ;
310
+ ask_to_run (
311
+ cmd,
312
+ ask_user,
313
+ "install the rustc-src component for the selected toolchain" ,
314
+ ) ;
315
+ }
316
+ rustup_src
332
317
}
333
318
} ;
334
319
if !rust_src. exists ( ) {
0 commit comments