Rollup merge of #137377 - bjorn3:crate_loader_cleanup, r=compiler-errors
Always allow reusing cratenum in CrateLoader::load The only case where can_reuse_cratenum could have been false in the past are rustc plugins, support for which has been removed over a year ago now. Nowadays the only case where locator.tuple is not target_triple is when loading a proc macro, in which case we also set can_reuse_cratenum to true. As such it is always true and we can remove some dead code.
This commit is contained in:
commit
f13feb34dc
1 changed files with 9 additions and 21 deletions
|
@ -762,29 +762,17 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||||
// against a hash, we could load a crate which has the same hash
|
// against a hash, we could load a crate which has the same hash
|
||||||
// as an already loaded crate. If this is the case prevent
|
// as an already loaded crate. If this is the case prevent
|
||||||
// duplicates by just using the first crate.
|
// duplicates by just using the first crate.
|
||||||
//
|
|
||||||
// Note that we only do this for target triple crates, though, as we
|
|
||||||
// don't want to match a host crate against an equivalent target one
|
|
||||||
// already loaded.
|
|
||||||
let root = library.metadata.get_root();
|
let root = library.metadata.get_root();
|
||||||
// FIXME: why is this condition necessary? It was adding in #33625 but I
|
let mut result = LoadResult::Loaded(library);
|
||||||
// don't know why and the original author doesn't remember ...
|
for (cnum, data) in self.cstore.iter_crate_data() {
|
||||||
let can_reuse_cratenum =
|
if data.name() == root.name() && root.hash() == data.hash() {
|
||||||
locator.tuple == self.sess.opts.target_triple || locator.is_proc_macro;
|
assert!(locator.hash.is_none());
|
||||||
Ok(Some(if can_reuse_cratenum {
|
info!("load success, going to previous cnum: {}", cnum);
|
||||||
let mut result = LoadResult::Loaded(library);
|
result = LoadResult::Previous(cnum);
|
||||||
for (cnum, data) in self.cstore.iter_crate_data() {
|
break;
|
||||||
if data.name() == root.name() && root.hash() == data.hash() {
|
|
||||||
assert!(locator.hash.is_none());
|
|
||||||
info!("load success, going to previous cnum: {}", cnum);
|
|
||||||
result = LoadResult::Previous(cnum);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result
|
}
|
||||||
} else {
|
Ok(Some(result))
|
||||||
LoadResult::Loaded(library)
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Go through the crate metadata and load any crates that it references.
|
/// Go through the crate metadata and load any crates that it references.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue