Reflect the "do not call this query directly" mentality in its name
This commit is contained in:
parent
c5889e4dab
commit
b8e6883a2f
6 changed files with 10 additions and 9 deletions
|
@ -1484,6 +1484,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedBrokenConst {
|
||||||
}
|
}
|
||||||
hir::ItemKind::Static(_, _, body_id) => {
|
hir::ItemKind::Static(_, _, body_id) => {
|
||||||
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
|
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
|
||||||
|
// FIXME: Use ensure here
|
||||||
let _ = cx.tcx.eval_static_initializer(def_id);
|
let _ = cx.tcx.eval_static_initializer(def_id);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -69,9 +69,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
// improve caching of queries.
|
// improve caching of queries.
|
||||||
let inputs = self.erase_regions(¶m_env.and(cid));
|
let inputs = self.erase_regions(¶m_env.and(cid));
|
||||||
if let Some(span) = span {
|
if let Some(span) = span {
|
||||||
self.at(span).eval_to_const_value(inputs)
|
self.at(span).eval_to_const_value_raw(inputs)
|
||||||
} else {
|
} else {
|
||||||
self.eval_to_const_value(inputs)
|
self.eval_to_const_value_raw(inputs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -724,7 +724,7 @@ rustc_queries! {
|
||||||
///
|
///
|
||||||
/// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
|
/// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
|
||||||
/// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
|
/// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
|
||||||
query eval_to_const_value(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
|
query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
|
||||||
-> EvalToConstValueResult<'tcx> {
|
-> EvalToConstValueResult<'tcx> {
|
||||||
desc { |tcx|
|
desc { |tcx|
|
||||||
"simplifying constant for the type system `{}`",
|
"simplifying constant for the type system `{}`",
|
||||||
|
|
|
@ -200,13 +200,13 @@ fn turn_into_const_value<'tcx>(
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!is_static || cid.promoted.is_some(),
|
!is_static || cid.promoted.is_some(),
|
||||||
"the `eval_to_const_value` query should not be used for statics, use `eval_to_allocation` instead"
|
"the `eval_to_const_value_raw` query should not be used for statics, use `eval_to_allocation` instead"
|
||||||
);
|
);
|
||||||
// Turn this into a proper constant.
|
// Turn this into a proper constant.
|
||||||
op_to_const(&ecx, mplace.into())
|
op_to_const(&ecx, mplace.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eval_to_const_value_provider<'tcx>(
|
pub fn eval_to_const_value_raw_provider<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
|
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
|
||||||
) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
|
) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
|
||||||
|
@ -214,7 +214,7 @@ pub fn eval_to_const_value_provider<'tcx>(
|
||||||
if key.param_env.reveal() == Reveal::All {
|
if key.param_env.reveal() == Reveal::All {
|
||||||
let mut key = key;
|
let mut key = key;
|
||||||
key.param_env = key.param_env.with_user_facing();
|
key.param_env = key.param_env.with_user_facing();
|
||||||
match tcx.eval_to_const_value(key) {
|
match tcx.eval_to_const_value_raw(key) {
|
||||||
// try again with reveal all as requested
|
// try again with reveal all as requested
|
||||||
Err(ErrorHandled::TooGeneric) => {}
|
Err(ErrorHandled::TooGeneric) => {}
|
||||||
// deduplicate calls
|
// deduplicate calls
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
transform::provide(providers);
|
transform::provide(providers);
|
||||||
monomorphize::partitioning::provide(providers);
|
monomorphize::partitioning::provide(providers);
|
||||||
monomorphize::polymorphize::provide(providers);
|
monomorphize::polymorphize::provide(providers);
|
||||||
providers.eval_to_const_value = const_eval::eval_to_const_value_provider;
|
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
|
||||||
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
|
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
|
||||||
providers.const_caller_location = const_eval::const_caller_location;
|
providers.const_caller_location = const_eval::const_caller_location;
|
||||||
providers.destructure_const = |tcx, param_env_and_value| {
|
providers.destructure_const = |tcx, param_env_and_value| {
|
||||||
|
|
|
@ -10,8 +10,8 @@ LL | let x: &'static i32 = &(1 / 0);
|
||||||
|
|
||||||
query stack during panic:
|
query stack during panic:
|
||||||
#0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[1]`
|
#0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[1]`
|
||||||
#1 [eval_to_const_value] simplifying constant for the type system `main::promoted[1]`
|
#1 [eval_to_const_value_raw] simplifying constant for the type system `main::promoted[1]`
|
||||||
#2 [eval_to_const_value] simplifying constant for the type system `main::promoted[1]`
|
#2 [eval_to_const_value_raw] simplifying constant for the type system `main::promoted[1]`
|
||||||
#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
|
#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
|
||||||
#4 [optimized_mir] optimizing MIR for `main`
|
#4 [optimized_mir] optimizing MIR for `main`
|
||||||
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
|
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue