diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-05-08 14:58:26 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-06-24 19:44:35 +0000 |
| commit | 5dfe72c1fda271e1147ac85aebf6d382145ee0c0 (patch) | |
| tree | 90bc8fe18a43d0e3d8259c50576aa7f452366195 | |
| parent | 5f63b5758969872add239e477b9a49cea08cc921 (diff) | |
| download | rust-5dfe72c1fda271e1147ac85aebf6d382145ee0c0.tar.gz rust-5dfe72c1fda271e1147ac85aebf6d382145ee0c0.zip | |
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.
| -rw-r--r-- | compiler/rustc_metadata/src/creader.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 60788a43bd7..2c882b84c58 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -952,27 +952,19 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { // If we need a panic runtime, we try to find an existing one here. At // the same time we perform some general validation of the DAG we've got // going such as ensuring everything has a compatible panic strategy. - let desired_strategy = self.sess.panic_strategy(); - let mut runtime_found = false; let mut needs_panic_runtime = attr::contains_name(&krate.attrs, sym::needs_panic_runtime); - for (_cnum, data) in self.cstore.iter_crate_data() { - needs_panic_runtime = needs_panic_runtime || data.needs_panic_runtime(); - if data.is_panic_runtime() { - runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit; - } + needs_panic_runtime |= data.needs_panic_runtime(); } - // If an explicitly linked and matching panic runtime was found, or if - // we just don't need one at all, then we're done here and there's - // nothing else to do. - if !needs_panic_runtime || runtime_found { + // If we just don't need a panic runtime at all, then we're done here + // and there's nothing else to do. + if !needs_panic_runtime { return; } - // By this point we know that we (a) need a panic runtime and (b) no - // panic runtime was explicitly linked. Here we just load an appropriate - // default runtime for our panic strategy. + // By this point we know that we need a panic runtime. Here we just load + // an appropriate default runtime for our panic strategy. // // We may resolve to an already loaded crate (as the crate may not have // been explicitly linked prior to this), but this is fine. @@ -980,6 +972,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { // Also note that we have yet to perform validation of the crate graph // in terms of everyone has a compatible panic runtime format, that's // performed later as part of the `dependency_format` module. + let desired_strategy = self.sess.panic_strategy(); let name = match desired_strategy { PanicStrategy::Unwind => sym::panic_unwind, PanicStrategy::Abort => sym::panic_abort, |
