Skip to content

Commit f13feb3

Browse files
authored
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.
2 parents b0286b5 + 2fc9205 commit f13feb3

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

Diff for: compiler/rustc_metadata/src/creader.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -762,29 +762,17 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
762762
// against a hash, we could load a crate which has the same hash
763763
// as an already loaded crate. If this is the case prevent
764764
// duplicates by just using the first crate.
765-
//
766-
// Note that we only do this for target triple crates, though, as we
767-
// don't want to match a host crate against an equivalent target one
768-
// already loaded.
769765
let root = library.metadata.get_root();
770-
// FIXME: why is this condition necessary? It was adding in #33625 but I
771-
// don't know why and the original author doesn't remember ...
772-
let can_reuse_cratenum =
773-
locator.tuple == self.sess.opts.target_triple || locator.is_proc_macro;
774-
Ok(Some(if can_reuse_cratenum {
775-
let mut result = LoadResult::Loaded(library);
776-
for (cnum, data) in self.cstore.iter_crate_data() {
777-
if data.name() == root.name() && root.hash() == data.hash() {
778-
assert!(locator.hash.is_none());
779-
info!("load success, going to previous cnum: {}", cnum);
780-
result = LoadResult::Previous(cnum);
781-
break;
782-
}
766+
let mut result = LoadResult::Loaded(library);
767+
for (cnum, data) in self.cstore.iter_crate_data() {
768+
if data.name() == root.name() && root.hash() == data.hash() {
769+
assert!(locator.hash.is_none());
770+
info!("load success, going to previous cnum: {}", cnum);
771+
result = LoadResult::Previous(cnum);
772+
break;
783773
}
784-
result
785-
} else {
786-
LoadResult::Loaded(library)
787-
}))
774+
}
775+
Ok(Some(result))
788776
}
789777

790778
/// Go through the crate metadata and load any crates that it references.

0 commit comments

Comments
 (0)