Skip to content

Commit aca66bd

Browse files
committed
WithOptConstParam::dummy -> WithOptConstParam::unknown
1 parent 8003ccf commit aca66bd

File tree

12 files changed

+21
-20
lines changed

12 files changed

+21
-20
lines changed

src/librustc_interface/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
892892

893893
if tcx.hir().body_const_context(def_id).is_some() {
894894
tcx.ensure()
895-
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::dummy(def_id));
895+
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::unknown(def_id));
896896
}
897897
}
898898
});

src/librustc_middle/ty/instance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'tcx> InstanceDef<'tcx> {
196196
| InstanceDef::Intrinsic(def_id)
197197
| InstanceDef::ClosureOnceShim { call_once: def_id }
198198
| InstanceDef::DropGlue(def_id, _)
199-
| InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::dummy(def_id),
199+
| InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::unknown(def_id),
200200
}
201201
}
202202

@@ -298,7 +298,7 @@ impl<'tcx> Instance<'tcx> {
298298
def_id,
299299
substs
300300
);
301-
Instance { def: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)), substs }
301+
Instance { def: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)), substs }
302302
}
303303

304304
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {

src/librustc_middle/ty/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,8 @@ pub struct WithOptConstParam<T> {
16131613
}
16141614

16151615
impl<T> WithOptConstParam<T> {
1616-
pub fn dummy(did: T) -> WithOptConstParam<T> {
1616+
/// Creates a new `WithOptConstParam` setting `const_param_did` to `None`.
1617+
pub fn unknown(did: T) -> WithOptConstParam<T> {
16171618
WithOptConstParam { did, const_param_did: None }
16181619
}
16191620
}

src/librustc_middle/ty/sty.rs

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

22162216
pub fn from_opt_const_arg_anon_const(

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
8888

8989
pub fn provide(providers: &mut Providers) {
9090
*providers = Providers {
91-
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::dummy(did)),
91+
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::unknown(did)),
9292
mir_borrowck_const_arg: |tcx, (did, param_did)| {
9393
mir_borrowck(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
9494
},

src/librustc_mir/transform/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
491491
pub(crate) fn provide(providers: &mut Providers) {
492492
*providers = Providers {
493493
unsafety_check_result: |tcx, def_id| {
494-
unsafety_check_result(tcx, ty::WithOptConstParam::dummy(def_id))
494+
unsafety_check_result(tcx, ty::WithOptConstParam::unknown(def_id))
495495
},
496496
unsafety_check_result_const_arg: |tcx, (did, param_did)| {
497497
unsafety_check_result(

src/librustc_mir/transform/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) fn provide(providers: &mut Providers) {
4949
mir_keys,
5050
mir_const,
5151
mir_const_qualif: |tcx, did| {
52-
mir_const_qualif(tcx, ty::WithOptConstParam::dummy(did.expect_local()))
52+
mir_const_qualif(tcx, ty::WithOptConstParam::unknown(did.expect_local()))
5353
},
5454
mir_const_qualif_const_arg: |tcx, (did, param_did)| {
5555
mir_const_qualif(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
@@ -60,7 +60,7 @@ pub(crate) fn provide(providers: &mut Providers) {
6060
optimized_mir_of_const_arg,
6161
is_mir_available,
6262
promoted_mir: |tcx, def_id| {
63-
promoted_mir(tcx, ty::WithOptConstParam::dummy(def_id.expect_local()))
63+
promoted_mir(tcx, ty::WithOptConstParam::unknown(def_id.expect_local()))
6464
},
6565
promoted_mir_of_const_arg: |tcx, (did, param_did)| {
6666
promoted_mir(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
@@ -128,7 +128,7 @@ pub struct MirSource<'tcx> {
128128
impl<'tcx> MirSource<'tcx> {
129129
pub fn item(def_id: DefId) -> Self {
130130
MirSource {
131-
instance: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
131+
instance: InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
132132
promoted: None,
133133
}
134134
}
@@ -414,7 +414,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(
414414
run_passes(
415415
tcx,
416416
body,
417-
InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
417+
InstanceDef::Item(ty::WithOptConstParam::unknown(def_id.to_def_id())),
418418
promoted,
419419
MirPhase::DropElab,
420420
&[post_borrowck_cleanup],
@@ -478,7 +478,7 @@ fn run_optimization_passes<'tcx>(
478478
run_passes(
479479
tcx,
480480
body,
481-
InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
481+
InstanceDef::Item(ty::WithOptConstParam::unknown(def_id.to_def_id())),
482482
promoted,
483483
MirPhase::Optimized,
484484
&[
@@ -493,7 +493,7 @@ fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx Body<'tcx> {
493493
if let Some(param_did) = tcx.opt_const_param_of(did) {
494494
tcx.optimized_mir_of_const_arg((did, param_did))
495495
} else {
496-
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::dummy(did)))
496+
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::unknown(did)))
497497
}
498498
}
499499

src/librustc_mir/util/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub fn write_mir_pretty<'tcx>(
249249
for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() {
250250
writeln!(w)?;
251251
let src = MirSource {
252-
instance: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
252+
instance: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(def_id)),
253253
promoted: Some(i),
254254
};
255255
write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?;

src/librustc_mir_build/hair/cx/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
601601
let substs = InternalSubsts::identity_for_item(cx.tcx(), did);
602602
let lhs = mk_const(cx.tcx().mk_const(ty::Const {
603603
val: ty::ConstKind::Unevaluated(
604-
ty::WithOptConstParam::dummy(did),
604+
ty::WithOptConstParam::unknown(did),
605605
substs,
606606
None,
607607
),
@@ -801,7 +801,7 @@ fn convert_path_expr<'a, 'tcx>(
801801
ExprKind::Literal {
802802
literal: cx.tcx.mk_const(ty::Const {
803803
val: ty::ConstKind::Unevaluated(
804-
ty::WithOptConstParam::dummy(def_id),
804+
ty::WithOptConstParam::unknown(def_id),
805805
substs,
806806
None,
807807
),

src/librustc_ty/instance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn resolve_instance<'tcx>(
2121
}
2222
}
2323

24-
inner_resolve_instance(tcx, param_env.and((ty::WithOptConstParam::dummy(did), substs)))
24+
inner_resolve_instance(tcx, param_env.and((ty::WithOptConstParam::unknown(did), substs)))
2525
}
2626

2727
fn resolve_instance_of_const_arg<'tcx>(
@@ -210,7 +210,7 @@ fn resolve_associated_item<'tcx>(
210210
Some(ty::Instance::new(leaf_def.item.def_id, substs))
211211
}
212212
traits::ImplSourceGenerator(generator_data) => Some(Instance {
213-
def: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(
213+
def: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(
214214
generator_data.generator_def_id,
215215
)),
216216
substs: generator_data.substs,

src/librustc_typeck/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ fn check_type_defn<'tcx, F>(
424424
cause,
425425
fcx.param_env,
426426
ty::PredicateKind::ConstEvaluatable(
427-
ty::WithOptConstParam::dummy(discr_def_id.to_def_id()),
427+
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
428428
discr_substs,
429429
)
430430
.to_predicate(fcx.tcx),

src/tools/clippy/clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
332332
let result = self
333333
.lcx
334334
.tcx
335-
.const_eval_resolve(self.param_env, ty::WithOptConstParam::dummy(def_id), substs, None, None)
335+
.const_eval_resolve(self.param_env, ty::WithOptConstParam::unknown(def_id), substs, None, None)
336336
.ok()
337337
.map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?;
338338
let result = miri_to_const(&result);

0 commit comments

Comments
 (0)