@@ -40,52 +40,23 @@ pub struct FileSearch<'a> {
40
40
41
41
impl < ' a > FileSearch < ' a > {
42
42
pub fn for_each_lib_search_path < F > ( & self , mut f : F ) where
43
- F : FnMut ( & Path , PathKind ) -> FileMatch ,
43
+ F : FnMut ( & Path , PathKind )
44
44
{
45
45
let mut visited_dirs = HashSet :: new ( ) ;
46
- let mut found = false ;
47
46
48
47
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) ;
53
49
visited_dirs. insert ( path. to_path_buf ( ) ) ;
54
50
}
55
51
56
52
debug ! ( "filesearch: searching lib path" ) ;
57
53
let tlib_path = make_target_lib_path ( self . sysroot ,
58
54
self . triple ) ;
59
55
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 ) ;
64
57
}
65
58
66
59
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
- }
89
60
}
90
61
91
62
pub fn get_lib_path ( & self ) -> PathBuf {
@@ -101,7 +72,6 @@ impl<'a> FileSearch<'a> {
101
72
Ok ( files) => {
102
73
let files = files. filter_map ( |p| p. ok ( ) . map ( |s| s. path ( ) ) )
103
74
. collect :: < Vec < _ > > ( ) ;
104
- let mut rslt = FileDoesntMatch ;
105
75
fn is_rlib ( p : & Path ) -> bool {
106
76
p. extension ( ) . and_then ( |s| s. to_str ( ) ) == Some ( "rlib" )
107
77
}
@@ -117,16 +87,14 @@ impl<'a> FileSearch<'a> {
117
87
match maybe_picked {
118
88
FileMatches => {
119
89
debug ! ( "picked {}" , path. display( ) ) ;
120
- rslt = FileMatches ;
121
90
}
122
91
FileDoesntMatch => {
123
92
debug ! ( "rejected {}" , path. display( ) ) ;
124
93
}
125
94
}
126
95
}
127
- rslt
128
96
}
129
- Err ( ..) => FileDoesntMatch ,
97
+ Err ( ..) => ( ) ,
130
98
}
131
99
} ) ;
132
100
}
@@ -149,7 +117,6 @@ impl<'a> FileSearch<'a> {
149
117
let mut paths = Vec :: new ( ) ;
150
118
self . for_each_lib_search_path ( |lib_search_path, _| {
151
119
paths. push ( lib_search_path. to_path_buf ( ) ) ;
152
- FileDoesntMatch
153
120
} ) ;
154
121
paths
155
122
}
@@ -179,14 +146,6 @@ fn make_target_lib_path(sysroot: &Path,
179
146
sysroot. join ( & relative_target_lib_path ( sysroot, target_triple) )
180
147
}
181
148
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
-
190
149
pub fn get_or_default_sysroot ( ) -> PathBuf {
191
150
// Follow symlinks. If the resolved path is relative, make it absolute.
192
151
fn canonicalize ( path : Option < PathBuf > ) -> Option < PathBuf > {
@@ -207,56 +166,6 @@ pub fn get_or_default_sysroot() -> PathBuf {
207
166
}
208
167
}
209
168
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
-
260
169
// The name of the directory rustc expects libraries to be located.
261
170
fn find_libdir ( sysroot : & Path ) -> String {
262
171
// FIXME: This is a quick hack to make the rustc binary able to locate
0 commit comments