Skip to content

Instantly share code, notes, and snippets.

@nebffa
Last active August 29, 2015 14:02
Show Gist options
  • Save nebffa/77905b33a9d4d56bcfa1 to your computer and use it in GitHub Desktop.
Save nebffa/77905b33a9d4d56bcfa1 to your computer and use it in GitHub Desktop.
The error:
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc
/vagrant/rust/src/librustc/metadata/loader.rs:209:32: 281:10 error: closure requires unique access to `self` but `self.filesearch` is already borrowed
/vagrant/rust/src/librustc/metadata/loader.rs:209 self.filesearch.search(|path| {
/vagrant/rust/src/librustc/metadata/loader.rs:210 let file = match path.filename_str() {
/vagrant/rust/src/librustc/metadata/loader.rs:211 None => return FileDoesntMatch,
/vagrant/rust/src/librustc/metadata/loader.rs:212 Some(file) => file,
/vagrant/rust/src/librustc/metadata/loader.rs:213 };
/vagrant/rust/src/librustc/metadata/loader.rs:214 if file.starts_with(rlib_prefix.as_slice()) &&
...
/vagrant/rust/src/librustc/metadata/loader.rs:217:23: 217:27 note: borrow occurs due to use of `self` in closure
/vagrant/rust/src/librustc/metadata/loader.rs:217 match self.try_match(file, rlib_prefix.as_slice(), ".rlib") {
^~~~
/vagrant/rust/src/librustc/metadata/loader.rs:209:9: 209:24 note: previous borrow of `self.filesearch` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `self.filesearch` until the borrow ends
/vagrant/rust/src/librustc/metadata/loader.rs:209 self.filesearch.search(|path| {
^~~~~~~~~~~~~~~
/vagrant/rust/src/librustc/metadata/loader.rs:281:11: 281:11 note: previous borrow ends here
/vagrant/rust/src/librustc/metadata/loader.rs:209 self.filesearch.search(|path| {
...
/vagrant/rust/src/librustc/metadata/loader.rs:281 });
The line in question is at line 58.
self.filesearch.search(|path| {
let file = match path.filename_str() {
None => return FileDoesntMatch,
Some(file) => file,
};
if file.starts_with(rlib_prefix.as_slice()) &&
file.ends_with(".rlib") {
info!("rlib candidate: {}", path.display());
match self.try_match(file, rlib_prefix.as_slice(), ".rlib") {
Some(hash) => {
info!("rlib accepted, hash: {}", hash);
let slot = candidates.find_or_insert_with(hash, |_| {
(HashSet::new(), HashSet::new(), HashSet::new())
});
let (ref mut rlibs, _, _) = *slot;
rlibs.insert(fs::realpath(path).unwrap());
FileMatches
}
None => {
info!("rlib rejected");
FileDoesntMatch
}
}
} else if file.starts_with(rlib_prefix.as_slice()) &&
file.ends_with(staticlib_suffix) {
match self.try_match(file,
rlib_prefix.as_slice(),
staticlib_suffix) {
Some(hash) => {
self.rejected_via_staticlib.push(CrateMismatch {
path: path.clone(),
got: "test".to_string()
});
info!("staticlib rejected");
FileDoesntMatch
}
None => {
info!("staticlib rejected");
FileDoesntMatch
}
}
} else if file.starts_with(dylib_prefix.as_slice()) &&
file.ends_with(dysuffix){
info!("dylib candidate: {}", path.display());
match self.try_match(file,
dylib_prefix.as_slice(),
dysuffix) {
Some(hash) => {
info!("dylib accepted, hash: {}", hash);
let slot = candidates.find_or_insert_with(hash, |_| {
(HashSet::new(), HashSet::new(), HashSet::new())
});
let (_, _, ref mut dylibs) = *slot;
dylibs.insert(fs::realpath(path).unwrap());
FileMatches
}
None => {
info!("dylib rejected");
FileDoesntMatch
}
}
} else {
FileDoesntMatch
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment