Skip to content

Commit 3a7ae67

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 2d2d70f commit 3a7ae67

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -952,34 +952,27 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
952952
// If we need a panic runtime, we try to find an existing one here. At
953953
// the same time we perform some general validation of the DAG we've got
954954
// going such as ensuring everything has a compatible panic strategy.
955-
let desired_strategy = self.sess.panic_strategy();
956-
let mut runtime_found = false;
957955
let mut needs_panic_runtime = attr::contains_name(&krate.attrs, sym::needs_panic_runtime);
958-
959956
for (_cnum, data) in self.cstore.iter_crate_data() {
960-
needs_panic_runtime = needs_panic_runtime || data.needs_panic_runtime();
961-
if data.is_panic_runtime() {
962-
runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit;
963-
}
957+
needs_panic_runtime |= data.needs_panic_runtime();
964958
}
965959

966-
// If an explicitly linked and matching panic runtime was found, or if
967-
// we just don't need one at all, then we're done here and there's
968-
// nothing else to do.
969-
if !needs_panic_runtime || runtime_found {
960+
// If we just don't need a panic runtime at all, then we're done here
961+
// and there's nothing else to do.
962+
if !needs_panic_runtime {
970963
return;
971964
}
972965

973-
// By this point we know that we (a) need a panic runtime and (b) no
974-
// panic runtime was explicitly linked. Here we just load an appropriate
975-
// default runtime for our panic strategy.
966+
// By this point we know that we need a panic runtime. Here we just load
967+
// an appropriate default runtime for our panic strategy.
976968
//
977969
// We may resolve to an already loaded crate (as the crate may not have
978970
// been explicitly linked prior to this), but this is fine.
979971
//
980972
// Also note that we have yet to perform validation of the crate graph
981973
// in terms of everyone has a compatible panic runtime format, that's
982974
// performed later as part of the `dependency_format` module.
975+
let desired_strategy = self.sess.panic_strategy();
983976
let name = match desired_strategy {
984977
PanicStrategy::Unwind => sym::panic_unwind,
985978
PanicStrategy::Abort => sym::panic_abort,

0 commit comments

Comments
 (0)