11use std:: env;
2- use std:: ffi:: OsStr ;
32use std:: hash:: { Hash , Hasher } ;
43use std:: path:: { Path , PathBuf } ;
54use std:: process:: Command ;
@@ -8,7 +7,6 @@ pub use rustc_version::version_meta as version;
87
98use serde_json;
109use serde_json:: Value ;
11- use walkdir:: WalkDir ;
1210
1311use errors:: * ;
1412use extensions:: CommandExt ;
@@ -65,38 +63,17 @@ impl Sysroot {
6563 & self . path
6664 }
6765
68- /// Returns the path to Rust source, `$SRC`, where `$SRC/libstd/Carg .toml`
66+ /// Returns the path to Rust source, `$SRC`, where `$SRC/std/Cargo .toml`
6967 /// exists
7068 pub fn src ( & self ) -> Result < Src > {
7169 let src = self . path ( ) . join ( "lib" ) . join ( "rustlib" ) . join ( "src" ) ;
7270
73- if src. join ( "rust/src/libstd /Cargo.toml" ) . is_file ( ) {
71+ if src. join ( "rust/library/std /Cargo.toml" ) . is_file ( ) {
7472 return Ok ( Src {
75- path : src. join ( "rust/src " ) ,
73+ path : src. join ( "rust/library " ) ,
7674 } ) ;
7775 }
7876
79- if src. exists ( ) {
80- for e in WalkDir :: new ( src) {
81- let e = e. chain_err ( || "couldn't walk the sysroot" ) ?;
82-
83- // Looking for $SRC/libstd/Cargo.toml
84- if e. file_type ( ) . is_file ( ) && e. file_name ( ) == "Cargo.toml" {
85- let toml = e. path ( ) ;
86-
87- if let Some ( std) = toml. parent ( ) {
88- if let Some ( src) = std. parent ( ) {
89- if std. file_name ( ) == Some ( OsStr :: new ( "libstd" ) ) {
90- return Ok ( Src {
91- path : src. to_owned ( ) ,
92- } ) ;
93- }
94- }
95- }
96- }
97- }
98- }
99-
10077 Err ( "`rust-src` component not found. Run `rustup component add \
10178 rust-src`.") ?
10279 }
0 commit comments