Skip to content

Commit 14d155a

Browse files
committed
Rename panic_strategy query to required_panic_strategy
1 parent 9e6c044 commit 14d155a

File tree

8 files changed

+13
-14
lines changed

8 files changed

+13
-14
lines changed

compiler/rustc_metadata/src/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ impl<'a> CrateLoader<'a> {
744744
if !data.is_panic_runtime() {
745745
self.sess.err(&format!("the crate `{}` is not a panic runtime", name));
746746
}
747-
if data.panic_strategy() != Some(desired_strategy) {
747+
if data.required_panic_strategy() != Some(desired_strategy) {
748748
self.sess.err(&format!(
749749
"the crate `{}` does not have the panic \
750750
strategy `{}`",

compiler/rustc_metadata/src/dependency_format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
368368
}
369369
panic_runtime = Some((
370370
cnum,
371-
tcx.panic_strategy(cnum).unwrap_or_else(|| {
371+
tcx.required_panic_strategy(cnum).unwrap_or_else(|| {
372372
bug!("cannot determine panic strategy of a panic runtime");
373373
}),
374374
));
@@ -406,7 +406,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
406406
continue;
407407
}
408408

409-
if let Some(found_strategy) = tcx.panic_strategy(cnum) && desired_strategy != found_strategy {
409+
if let Some(found_strategy) = tcx.required_panic_strategy(cnum) && desired_strategy != found_strategy {
410410
sess.err(&format!(
411411
"the crate `{}` requires \
412412
panic strategy `{}` which is \

compiler/rustc_metadata/src/rmeta/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1759,8 +1759,8 @@ impl CrateMetadata {
17591759
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
17601760
}
17611761

1762-
pub(crate) fn panic_strategy(&self) -> Option<PanicStrategy> {
1763-
self.root.panic_strategy
1762+
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
1763+
self.root.required_panic_strategy
17641764
}
17651765

17661766
pub(crate) fn needs_panic_runtime(&self) -> bool {

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
246246
has_global_allocator => { cdata.root.has_global_allocator }
247247
has_panic_handler => { cdata.root.has_panic_handler }
248248
is_profiler_runtime => { cdata.root.profiler_runtime }
249-
panic_strategy => { cdata.root.panic_strategy }
249+
required_panic_strategy => { cdata.root.required_panic_strategy }
250250
panic_in_drop_strategy => { cdata.root.panic_in_drop_strategy }
251251
extern_crate => {
252252
let r = *cdata.extern_crate.lock();

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
665665
triple: tcx.sess.opts.target_triple.clone(),
666666
hash: tcx.crate_hash(LOCAL_CRATE),
667667
stable_crate_id: tcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(),
668-
panic_strategy: tcx.required_panic_strategy(()),
668+
required_panic_strategy: tcx.required_panic_strategy(LOCAL_CRATE),
669669
panic_in_drop_strategy: tcx.sess.opts.debugging_opts.panic_in_drop,
670670
edition: tcx.sess.edition(),
671671
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),

compiler/rustc_metadata/src/rmeta/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub(crate) struct CrateRoot {
217217
extra_filename: String,
218218
hash: Svh,
219219
stable_crate_id: StableCrateId,
220-
panic_strategy: Option<PanicStrategy>,
220+
required_panic_strategy: Option<PanicStrategy>,
221221
panic_in_drop_strategy: PanicStrategy,
222222
edition: Edition,
223223
has_global_allocator: bool,

compiler/rustc_middle/src/query/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1369,10 +1369,7 @@ rustc_queries! {
13691369
desc { |tcx| "check if `{}` contains FFI-unwind calls", tcx.def_path_str(key.to_def_id()) }
13701370
cache_on_disk_if { true }
13711371
}
1372-
query required_panic_strategy(_: ()) -> Option<PanicStrategy> {
1373-
desc { "compute the required panic strategy for the current crate" }
1374-
}
1375-
query panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
1372+
query required_panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
13761373
fatal_cycle
13771374
desc { "query a crate's required panic strategy" }
13781375
separate_provide_extern

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
1+
use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE};
22
use rustc_middle::mir::*;
33
use rustc_middle::ty::layout;
44
use rustc_middle::ty::query::Providers;
@@ -123,7 +123,9 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
123123
tainted
124124
}
125125

126-
fn required_panic_strategy(tcx: TyCtxt<'_>, (): ()) -> Option<PanicStrategy> {
126+
fn required_panic_strategy(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<PanicStrategy> {
127+
assert_eq!(cnum, LOCAL_CRATE);
128+
127129
if tcx.is_panic_runtime(LOCAL_CRATE) {
128130
return Some(tcx.sess.panic_strategy());
129131
}

0 commit comments

Comments
 (0)