@@ -40,52 +40,23 @@ pub struct FileSearch<'a> {
4040
4141impl < ' a > FileSearch < ' a > {
4242 pub fn for_each_lib_search_path < F > ( & self , mut f : F ) where
43- F : FnMut ( & Path , PathKind ) -> FileMatch ,
43+ F : FnMut ( & Path , PathKind )
4444 {
4545 let mut visited_dirs = HashSet :: new ( ) ;
46- let mut found = false ;
4746
4847 for ( path, kind) in self . search_paths . iter ( self . kind ) {
49- match f ( path, kind) {
50- FileMatches => found = true ,
51- FileDoesntMatch => ( )
52- }
48+ f ( path, kind) ;
5349 visited_dirs. insert ( path. to_path_buf ( ) ) ;
5450 }
5551
5652 debug ! ( "filesearch: searching lib path" ) ;
5753 let tlib_path = make_target_lib_path ( self . sysroot ,
5854 self . triple ) ;
5955 if !visited_dirs. contains ( & tlib_path) {
60- match f ( & tlib_path, PathKind :: All ) {
61- FileMatches => found = true ,
62- FileDoesntMatch => ( )
63- }
56+ f ( & tlib_path, PathKind :: All ) ;
6457 }
6558
6659 visited_dirs. insert ( tlib_path) ;
67- // Try RUST_PATH
68- if !found {
69- let rustpath = rust_path ( ) ;
70- for path in & rustpath {
71- let tlib_path = make_rustpkg_lib_path (
72- self . sysroot , path, self . triple ) ;
73- debug ! ( "is {} in visited_dirs? {}" , tlib_path. display( ) ,
74- visited_dirs. contains( & tlib_path) ) ;
75-
76- if !visited_dirs. contains ( & tlib_path) {
77- visited_dirs. insert ( tlib_path. clone ( ) ) ;
78- // Don't keep searching the RUST_PATH if one match turns up --
79- // if we did, we'd get a "multiple matching crates" error
80- match f ( & tlib_path, PathKind :: All ) {
81- FileMatches => {
82- break ;
83- }
84- FileDoesntMatch => ( )
85- }
86- }
87- }
88- }
8960 }
9061
9162 pub fn get_lib_path ( & self ) -> PathBuf {
@@ -101,7 +72,6 @@ impl<'a> FileSearch<'a> {
10172 Ok ( files) => {
10273 let files = files. filter_map ( |p| p. ok ( ) . map ( |s| s. path ( ) ) )
10374 . collect :: < Vec < _ > > ( ) ;
104- let mut rslt = FileDoesntMatch ;
10575 fn is_rlib ( p : & Path ) -> bool {
10676 p. extension ( ) . and_then ( |s| s. to_str ( ) ) == Some ( "rlib" )
10777 }
@@ -117,16 +87,14 @@ impl<'a> FileSearch<'a> {
11787 match maybe_picked {
11888 FileMatches => {
11989 debug ! ( "picked {}" , path. display( ) ) ;
120- rslt = FileMatches ;
12190 }
12291 FileDoesntMatch => {
12392 debug ! ( "rejected {}" , path. display( ) ) ;
12493 }
12594 }
12695 }
127- rslt
12896 }
129- Err ( ..) => FileDoesntMatch ,
97+ Err ( ..) => ( ) ,
13098 }
13199 } ) ;
132100 }
@@ -149,7 +117,6 @@ impl<'a> FileSearch<'a> {
149117 let mut paths = Vec :: new ( ) ;
150118 self . for_each_lib_search_path ( |lib_search_path, _| {
151119 paths. push ( lib_search_path. to_path_buf ( ) ) ;
152- FileDoesntMatch
153120 } ) ;
154121 paths
155122 }
@@ -179,14 +146,6 @@ fn make_target_lib_path(sysroot: &Path,
179146 sysroot. join ( & relative_target_lib_path ( sysroot, target_triple) )
180147}
181148
182- fn make_rustpkg_lib_path ( sysroot : & Path ,
183- dir : & Path ,
184- triple : & str ) -> PathBuf {
185- let mut p = dir. join ( & find_libdir ( sysroot) ) ;
186- p. push ( triple) ;
187- p
188- }
189-
190149pub fn get_or_default_sysroot ( ) -> PathBuf {
191150 // Follow symlinks. If the resolved path is relative, make it absolute.
192151 fn canonicalize ( path : Option < PathBuf > ) -> Option < PathBuf > {
@@ -207,56 +166,6 @@ pub fn get_or_default_sysroot() -> PathBuf {
207166 }
208167}
209168
210- #[ cfg( windows) ]
211- const PATH_ENTRY_SEPARATOR : char = ';' ;
212- #[ cfg( not( windows) ) ]
213- const PATH_ENTRY_SEPARATOR : char = ':' ;
214-
215- /// Returns RUST_PATH as a string, without default paths added
216- pub fn get_rust_path ( ) -> Option < String > {
217- env:: var ( "RUST_PATH" ) . ok ( )
218- }
219-
220- /// Returns the value of RUST_PATH, as a list
221- /// of Paths. Includes default entries for, if they exist:
222- /// $HOME/.rust
223- /// DIR/.rust for any DIR that's the current working directory
224- /// or an ancestor of it
225- pub fn rust_path ( ) -> Vec < PathBuf > {
226- let mut env_rust_path: Vec < PathBuf > = match get_rust_path ( ) {
227- Some ( env_path) => {
228- let env_path_components =
229- env_path. split ( PATH_ENTRY_SEPARATOR ) ;
230- env_path_components. map ( |s| PathBuf :: from ( s) ) . collect ( )
231- }
232- None => Vec :: new ( )
233- } ;
234- let cwd = env:: current_dir ( ) . unwrap ( ) ;
235- // now add in default entries
236- let cwd_dot_rust = cwd. join ( ".rust" ) ;
237- if !env_rust_path. contains ( & cwd_dot_rust) {
238- env_rust_path. push ( cwd_dot_rust) ;
239- }
240- if !env_rust_path. contains ( & cwd) {
241- env_rust_path. push ( cwd. clone ( ) ) ;
242- }
243- let mut cur = & * cwd;
244- while let Some ( parent) = cur. parent ( ) {
245- let candidate = parent. join ( ".rust" ) ;
246- if !env_rust_path. contains ( & candidate) && candidate. exists ( ) {
247- env_rust_path. push ( candidate. clone ( ) ) ;
248- }
249- cur = parent;
250- }
251- if let Some ( h) = env:: home_dir ( ) {
252- let p = h. join ( ".rust" ) ;
253- if !env_rust_path. contains ( & p) && p. exists ( ) {
254- env_rust_path. push ( p) ;
255- }
256- }
257- env_rust_path
258- }
259-
260169// The name of the directory rustc expects libraries to be located.
261170fn find_libdir ( sysroot : & Path ) -> String {
262171 // FIXME: This is a quick hack to make the rustc binary able to locate
0 commit comments