Skip to content

Commit 86963ca

Browse files
committed
Stop handling explicit dependencies on the panic runtime
You shouldn't ever need to explicitly depend on it. And we weren't checking that the panic runtime used the correct panic strategy either.
1 parent 1fa5db2 commit 86963ca

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

compiler/rustc_metadata/src/creader.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -930,34 +930,27 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
930930
// If we need a panic runtime, we try to find an existing one here. At
931931
// the same time we perform some general validation of the DAG we've got
932932
// going such as ensuring everything has a compatible panic strategy.
933-
let desired_strategy = self.sess.panic_strategy();
934-
let mut runtime_found = false;
935933
let mut needs_panic_runtime = attr::contains_name(&krate.attrs, sym::needs_panic_runtime);
936-
937934
for (_cnum, data) in self.cstore.iter_crate_data() {
938-
needs_panic_runtime = needs_panic_runtime || data.needs_panic_runtime();
939-
if data.is_panic_runtime() {
940-
runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit;
941-
}
935+
needs_panic_runtime |= data.needs_panic_runtime();
942936
}
943937

944-
// If an explicitly linked and matching panic runtime was found, or if
945-
// we just don't need one at all, then we're done here and there's
946-
// nothing else to do.
947-
if !needs_panic_runtime || runtime_found {
938+
// If we just don't need a panic runtime at all, then we're done here
939+
// and there's nothing else to do.
940+
if !needs_panic_runtime {
948941
return;
949942
}
950943

951-
// By this point we know that we (a) need a panic runtime and (b) no
952-
// panic runtime was explicitly linked. Here we just load an appropriate
953-
// default runtime for our panic strategy.
944+
// By this point we know that we need a panic runtime. Here we just load
945+
// an appropriate default runtime for our panic strategy.
954946
//
955947
// We may resolve to an already loaded crate (as the crate may not have
956948
// been explicitly linked prior to this), but this is fine.
957949
//
958950
// Also note that we have yet to perform validation of the crate graph
959951
// in terms of everyone has a compatible panic runtime format, that's
960952
// performed later as part of the `dependency_format` module.
953+
let desired_strategy = self.sess.panic_strategy();
961954
let name = match desired_strategy {
962955
PanicStrategy::Unwind => sym::panic_unwind,
963956
PanicStrategy::Abort => sym::panic_abort,

0 commit comments

Comments
 (0)