WithOptConstParam::dummy -> WithOptConstParam::unknown

This commit is contained in:
Bastian Kauschke 2020-07-15 10:55:41 +02:00
parent 8003ccfdcd
commit aca66bd052
12 changed files with 21 additions and 20 deletions

View file

@ -892,7 +892,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
if tcx.hir().body_const_context(def_id).is_some() {
tcx.ensure()
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::dummy(def_id));
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::unknown(def_id));
}
}
});

View file

@ -196,7 +196,7 @@ impl<'tcx> InstanceDef<'tcx> {
| InstanceDef::Intrinsic(def_id)
| InstanceDef::ClosureOnceShim { call_once: def_id }
| InstanceDef::DropGlue(def_id, _)
| InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::dummy(def_id),
| InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::unknown(def_id),
}
}
@ -298,7 +298,7 @@ impl<'tcx> Instance<'tcx> {
def_id,
substs
);
Instance { def: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)), substs }
Instance { def: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)), substs }
}
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {

View file

@ -1613,7 +1613,8 @@ pub struct WithOptConstParam<T> {
}
impl<T> WithOptConstParam<T> {
pub fn dummy(did: T) -> WithOptConstParam<T> {
/// Creates a new `WithOptConstParam` setting `const_param_did` to `None`.
pub fn unknown(did: T) -> WithOptConstParam<T> {
WithOptConstParam { did, const_param_did: None }
}
}

View file

@ -2210,7 +2210,7 @@ impl<'tcx> Const<'tcx> {
/// Literals and const generic parameters are eagerly converted to a constant, everything else
/// becomes `Unevaluated`.
pub fn from_anon_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx Self {
Self::from_opt_const_arg_anon_const(tcx, ty::WithOptConstParam::dummy(def_id))
Self::from_opt_const_arg_anon_const(tcx, ty::WithOptConstParam::unknown(def_id))
}
pub fn from_opt_const_arg_anon_const(

View file

@ -88,7 +88,7 @@ const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
pub fn provide(providers: &mut Providers) {
*providers = Providers {
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::dummy(did)),
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::unknown(did)),
mir_borrowck_const_arg: |tcx, (did, param_did)| {
mir_borrowck(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
},

View file

@ -491,7 +491,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers {
unsafety_check_result: |tcx, def_id| {
unsafety_check_result(tcx, ty::WithOptConstParam::dummy(def_id))
unsafety_check_result(tcx, ty::WithOptConstParam::unknown(def_id))
},
unsafety_check_result_const_arg: |tcx, (did, param_did)| {
unsafety_check_result(

View file

@ -49,7 +49,7 @@ pub(crate) fn provide(providers: &mut Providers) {
mir_keys,
mir_const,
mir_const_qualif: |tcx, did| {
mir_const_qualif(tcx, ty::WithOptConstParam::dummy(did.expect_local()))
mir_const_qualif(tcx, ty::WithOptConstParam::unknown(did.expect_local()))
},
mir_const_qualif_const_arg: |tcx, (did, param_did)| {
mir_const_qualif(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
@ -60,7 +60,7 @@ pub(crate) fn provide(providers: &mut Providers) {
optimized_mir_of_const_arg,
is_mir_available,
promoted_mir: |tcx, def_id| {
promoted_mir(tcx, ty::WithOptConstParam::dummy(def_id.expect_local()))
promoted_mir(tcx, ty::WithOptConstParam::unknown(def_id.expect_local()))
},
promoted_mir_of_const_arg: |tcx, (did, param_did)| {
promoted_mir(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
@ -128,7 +128,7 @@ pub struct MirSource<'tcx> {
impl<'tcx> MirSource<'tcx> {
pub fn item(def_id: DefId) -> Self {
MirSource {
instance: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
instance: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
promoted: None,
}
}
@ -414,7 +414,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(
run_passes(
tcx,
body,
InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
InstanceDef::Item(ty::WithOptConstParam::unknown(def_id.to_def_id())),
promoted,
MirPhase::DropElab,
&[post_borrowck_cleanup],
@ -478,7 +478,7 @@ fn run_optimization_passes<'tcx>(
run_passes(
tcx,
body,
InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
InstanceDef::Item(ty::WithOptConstParam::unknown(def_id.to_def_id())),
promoted,
MirPhase::Optimized,
&[
@ -493,7 +493,7 @@ fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx Body<'tcx> {
if let Some(param_did) = tcx.opt_const_param_of(did) {
tcx.optimized_mir_of_const_arg((did, param_did))
} else {
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::dummy(did)))
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::unknown(did)))
}
}

View file

@ -249,7 +249,7 @@ pub fn write_mir_pretty<'tcx>(
for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() {
writeln!(w)?;
let src = MirSource {
instance: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
instance: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
promoted: Some(i),
};
write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?;

View file

@ -601,7 +601,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
let substs = InternalSubsts::identity_for_item(cx.tcx(), did);
let lhs = mk_const(cx.tcx().mk_const(ty::Const {
val: ty::ConstKind::Unevaluated(
ty::WithOptConstParam::dummy(did),
ty::WithOptConstParam::unknown(did),
substs,
None,
),
@ -801,7 +801,7 @@ fn convert_path_expr<'a, 'tcx>(
ExprKind::Literal {
literal: cx.tcx.mk_const(ty::Const {
val: ty::ConstKind::Unevaluated(
ty::WithOptConstParam::dummy(def_id),
ty::WithOptConstParam::unknown(def_id),
substs,
None,
),

View file

@ -21,7 +21,7 @@ fn resolve_instance<'tcx>(
}
}
inner_resolve_instance(tcx, param_env.and((ty::WithOptConstParam::dummy(did), substs)))
inner_resolve_instance(tcx, param_env.and((ty::WithOptConstParam::unknown(did), substs)))
}
fn resolve_instance_of_const_arg<'tcx>(
@ -210,7 +210,7 @@ fn resolve_associated_item<'tcx>(
Some(ty::Instance::new(leaf_def.item.def_id, substs))
}
traits::ImplSourceGenerator(generator_data) => Some(Instance {
def: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(
def: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(
generator_data.generator_def_id,
)),
substs: generator_data.substs,

View file

@ -424,7 +424,7 @@ fn check_type_defn<'tcx, F>(
cause,
fcx.param_env,
ty::PredicateKind::ConstEvaluatable(
ty::WithOptConstParam::dummy(discr_def_id.to_def_id()),
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
discr_substs,
)
.to_predicate(fcx.tcx),

View file

@ -332,7 +332,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
let result = self
.lcx
.tcx
.const_eval_resolve(self.param_env, ty::WithOptConstParam::dummy(def_id), substs, None, None)
.const_eval_resolve(self.param_env, ty::WithOptConstParam::unknown(def_id), substs, None, None)
.ok()
.map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?;
let result = miri_to_const(&result);