Rename panic_strategy query to required_panic_strategy

This commit is contained in:
Gary Guo 2022-06-08 21:32:17 +01:00
parent 9e6c044ee6
commit 14d155a3dc
8 changed files with 13 additions and 14 deletions

View File

@ -744,7 +744,7 @@ impl<'a> CrateLoader<'a> {
if !data.is_panic_runtime() {
self.sess.err(&format!("the crate `{}` is not a panic runtime", name));
}
if data.panic_strategy() != Some(desired_strategy) {
if data.required_panic_strategy() != Some(desired_strategy) {
self.sess.err(&format!(
"the crate `{}` does not have the panic \
strategy `{}`",

View File

@ -368,7 +368,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
}
panic_runtime = Some((
cnum,
tcx.panic_strategy(cnum).unwrap_or_else(|| {
tcx.required_panic_strategy(cnum).unwrap_or_else(|| {
bug!("cannot determine panic strategy of a panic runtime");
}),
));
@ -406,7 +406,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
continue;
}
if let Some(found_strategy) = tcx.panic_strategy(cnum) && desired_strategy != found_strategy {
if let Some(found_strategy) = tcx.required_panic_strategy(cnum) && desired_strategy != found_strategy {
sess.err(&format!(
"the crate `{}` requires \
panic strategy `{}` which is \

View File

@ -1759,8 +1759,8 @@ impl CrateMetadata {
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
}
pub(crate) fn panic_strategy(&self) -> Option<PanicStrategy> {
self.root.panic_strategy
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
self.root.required_panic_strategy
}
pub(crate) fn needs_panic_runtime(&self) -> bool {

View File

@ -246,7 +246,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
has_global_allocator => { cdata.root.has_global_allocator }
has_panic_handler => { cdata.root.has_panic_handler }
is_profiler_runtime => { cdata.root.profiler_runtime }
panic_strategy => { cdata.root.panic_strategy }
required_panic_strategy => { cdata.root.required_panic_strategy }
panic_in_drop_strategy => { cdata.root.panic_in_drop_strategy }
extern_crate => {
let r = *cdata.extern_crate.lock();

View File

@ -665,7 +665,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
triple: tcx.sess.opts.target_triple.clone(),
hash: tcx.crate_hash(LOCAL_CRATE),
stable_crate_id: tcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(),
panic_strategy: tcx.required_panic_strategy(()),
required_panic_strategy: tcx.required_panic_strategy(LOCAL_CRATE),
panic_in_drop_strategy: tcx.sess.opts.debugging_opts.panic_in_drop,
edition: tcx.sess.edition(),
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),

View File

@ -217,7 +217,7 @@ pub(crate) struct CrateRoot {
extra_filename: String,
hash: Svh,
stable_crate_id: StableCrateId,
panic_strategy: Option<PanicStrategy>,
required_panic_strategy: Option<PanicStrategy>,
panic_in_drop_strategy: PanicStrategy,
edition: Edition,
has_global_allocator: bool,

View File

@ -1369,10 +1369,7 @@ rustc_queries! {
desc { |tcx| "check if `{}` contains FFI-unwind calls", tcx.def_path_str(key.to_def_id()) }
cache_on_disk_if { true }
}
query required_panic_strategy(_: ()) -> Option<PanicStrategy> {
desc { "compute the required panic strategy for the current crate" }
}
query panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
query required_panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
fatal_cycle
desc { "query a crate's required panic strategy" }
separate_provide_extern

View File

@ -1,4 +1,4 @@
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE};
use rustc_middle::mir::*;
use rustc_middle::ty::layout;
use rustc_middle::ty::query::Providers;
@ -123,7 +123,9 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
tainted
}
fn required_panic_strategy(tcx: TyCtxt<'_>, (): ()) -> Option<PanicStrategy> {
fn required_panic_strategy(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<PanicStrategy> {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.is_panic_runtime(LOCAL_CRATE) {
return Some(tcx.sess.panic_strategy());
}