Skip to content

Commit a705e65

Browse files
committed
rename Unevaluated to UnevaluatedConst
1 parent efb9089 commit a705e65

File tree

35 files changed

+121
-91
lines changed

35 files changed

+121
-91
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub(crate) fn codegen_constant<'tcx>(
109109
) -> CValue<'tcx> {
110110
let (const_val, ty) = match fx.monomorphize(constant.literal) {
111111
ConstantKind::Ty(const_) => unreachable!("{:?}", const_),
112-
ConstantKind::Unevaluated(mir::Unevaluated { def, substs, promoted }, ty)
112+
ConstantKind::Unevaluated(mir::UnevaluatedConst { def, substs, promoted }, ty)
113113
if fx.tcx.is_static(def.did) =>
114114
{
115115
assert!(substs.is_empty());

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,15 @@ where
357357
ConstantKind::Val(..) => None,
358358
};
359359

360-
if let Some(mir::Unevaluated { def, substs: _, promoted }) = uneval {
360+
if let Some(mir::UnevaluatedConst { def, substs: _, promoted }) = uneval {
361361
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
362362
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
363363
// check performed after the promotion. Verify that with an assertion.
364364
assert!(promoted.is_none() || Q::ALLOW_PROMOTED);
365365

366366
// Don't peek inside trait associated constants.
367367
if promoted.is_none() && cx.tcx.trait_of_item(def.did).is_none() {
368+
assert_eq!(def.const_param_did, None, "expected associated const: {def:?}");
368369
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def.did);
369370

370371
if !Q::in_qualifs(&qualifs) {

compiler/rustc_const_eval/src/transform/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
841841
promoted.span = span;
842842
promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span);
843843
let substs = tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def.did));
844-
let uneval = mir::Unevaluated { def, substs, promoted: Some(promoted_id) };
844+
let uneval = mir::UnevaluatedConst { def, substs, promoted: Some(promoted_id) };
845845

846846
Operand::Constant(Box::new(Constant {
847847
span,

compiler/rustc_infer/src/infer/combine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
742742
}
743743
}
744744
}
745-
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs }) => {
745+
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => {
746746
let substs = self.relate_with_variance(
747747
ty::Variance::Invariant,
748748
ty::VarianceDiagInfo::default(),
@@ -751,7 +751,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
751751
)?;
752752
Ok(self.tcx().mk_const(ty::ConstS {
753753
ty: c.ty(),
754-
kind: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs }),
754+
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
755755
}))
756756
}
757757
_ => relate::super_relate_consts(self, c, c),
@@ -962,7 +962,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
962962
}
963963
}
964964
}
965-
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs }) => {
965+
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => {
966966
let substs = self.relate_with_variance(
967967
ty::Variance::Invariant,
968968
ty::VarianceDiagInfo::default(),
@@ -972,7 +972,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
972972

973973
Ok(self.tcx().mk_const(ty::ConstS {
974974
ty: c.ty(),
975-
kind: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs }),
975+
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
976976
}))
977977
}
978978
_ => relate::super_relate_consts(self, c, c),

compiler/rustc_infer/src/infer/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
705705
#[instrument(skip(self), level = "debug")]
706706
pub fn try_unify_abstract_consts(
707707
&self,
708-
a: ty::Unevaluated<'tcx>,
709-
b: ty::Unevaluated<'tcx>,
708+
a: ty::UnevaluatedConst<'tcx>,
709+
b: ty::UnevaluatedConst<'tcx>,
710710
param_env: ty::ParamEnv<'tcx>,
711711
) -> bool {
712712
// Reject any attempt to unify two unevaluated constants that contain inference
@@ -1690,7 +1690,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
16901690
pub fn try_const_eval_resolve(
16911691
&self,
16921692
param_env: ty::ParamEnv<'tcx>,
1693-
unevaluated: ty::Unevaluated<'tcx>,
1693+
unevaluated: ty::UnevaluatedConst<'tcx>,
16941694
ty: Ty<'tcx>,
16951695
span: Option<Span>,
16961696
) -> Result<ty::Const<'tcx>, ErrorHandled> {
@@ -1725,7 +1725,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17251725
pub fn const_eval_resolve(
17261726
&self,
17271727
mut param_env: ty::ParamEnv<'tcx>,
1728-
unevaluated: ty::Unevaluated<'tcx>,
1728+
unevaluated: ty::UnevaluatedConst<'tcx>,
17291729
span: Option<Span>,
17301730
) -> EvalToValTreeResult<'tcx> {
17311731
let mut substs = self.resolve_vars_if_possible(unevaluated.substs);
@@ -1756,7 +1756,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17561756
debug!(?param_env_erased);
17571757
debug!(?substs_erased);
17581758

1759-
let unevaluated = ty::Unevaluated { def: unevaluated.def, substs: substs_erased };
1759+
let unevaluated = ty::UnevaluatedConst { def: unevaluated.def, substs: substs_erased };
17601760

17611761
// The return value is the evaluated value which doesn't contain any reference to inference
17621762
// variables, thus we don't need to substitute back the original values.

compiler/rustc_middle/src/mir/interpret/queries.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> TyCtxt<'tcx> {
3636
pub fn const_eval_resolve(
3737
self,
3838
param_env: ty::ParamEnv<'tcx>,
39-
ct: mir::Unevaluated<'tcx>,
39+
ct: mir::UnevaluatedConst<'tcx>,
4040
span: Option<Span>,
4141
) -> EvalToConstValueResult<'tcx> {
4242
// Cannot resolve `Unevaluated` constants that contain inference
@@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> {
5151

5252
match ty::Instance::resolve_opt_const_arg(
5353
self, param_env,
54-
// FIXME: maybe have a seperate version for resolving mir::Unevaluated?
54+
// FIXME: maybe have a seperate version for resolving mir::UnevaluatedConst?
5555
ct.def, ct.substs,
5656
) {
5757
Ok(Some(instance)) => {
@@ -67,7 +67,7 @@ impl<'tcx> TyCtxt<'tcx> {
6767
pub fn const_eval_resolve_for_typeck(
6868
self,
6969
param_env: ty::ParamEnv<'tcx>,
70-
ct: ty::Unevaluated<'tcx>,
70+
ct: ty::UnevaluatedConst<'tcx>,
7171
span: Option<Span>,
7272
) -> EvalToValTreeResult<'tcx> {
7373
// Cannot resolve `Unevaluated` constants that contain inference

compiler/rustc_middle/src/mir/mod.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ pub enum ConstantKind<'tcx> {
20552055
Ty(ty::Const<'tcx>),
20562056

20572057
/// An unevaluated mir constant which is not part of the type system.
2058-
Unevaluated(Unevaluated<'tcx>, Ty<'tcx>),
2058+
Unevaluated(UnevaluatedConst<'tcx>, Ty<'tcx>),
20592059

20602060
/// This constant cannot go back into the type system, as it represents
20612061
/// something the type system cannot handle (e.g. pointers).
@@ -2315,7 +2315,7 @@ impl<'tcx> ConstantKind<'tcx> {
23152315
ty::InlineConstSubsts::new(tcx, ty::InlineConstSubstsParts { parent_substs, ty })
23162316
.substs;
23172317

2318-
let uneval = Unevaluated {
2318+
let uneval = UnevaluatedConst {
23192319
def: ty::WithOptConstParam::unknown(def_id).to_global(),
23202320
substs,
23212321
promoted: None,
@@ -2403,7 +2403,7 @@ impl<'tcx> ConstantKind<'tcx> {
24032403

24042404
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
24052405
let span = tcx.hir().span(hir_id);
2406-
let uneval = Unevaluated::new(def.to_global(), substs);
2406+
let uneval = UnevaluatedConst::new(def.to_global(), substs);
24072407
debug!(?span, ?param_env);
24082408

24092409
match tcx.const_eval_resolve(param_env, uneval, Some(span)) {
@@ -2416,7 +2416,7 @@ impl<'tcx> ConstantKind<'tcx> {
24162416
// Error was handled in `const_eval_resolve`. Here we just create a
24172417
// new unevaluated const and error hard later in codegen
24182418
Self::Unevaluated(
2419-
Unevaluated {
2419+
UnevaluatedConst {
24202420
def: def.to_global(),
24212421
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
24222422
promoted: None,
@@ -2442,25 +2442,28 @@ impl<'tcx> ConstantKind<'tcx> {
24422442
/// An unevaluated (potentially generic) constant used in MIR.
24432443
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable, Lift)]
24442444
#[derive(Hash, HashStable)]
2445-
pub struct Unevaluated<'tcx> {
2445+
pub struct UnevaluatedConst<'tcx> {
24462446
pub def: ty::WithOptConstParam<DefId>,
24472447
pub substs: SubstsRef<'tcx>,
24482448
pub promoted: Option<Promoted>,
24492449
}
24502450

2451-
impl<'tcx> Unevaluated<'tcx> {
2451+
impl<'tcx> UnevaluatedConst<'tcx> {
24522452
// FIXME: probably should get rid of this method. It's also wrong to
24532453
// shrink and then later expand a promoted.
24542454
#[inline]
2455-
pub fn shrink(self) -> ty::Unevaluated<'tcx> {
2456-
ty::Unevaluated { def: self.def, substs: self.substs }
2455+
pub fn shrink(self) -> ty::UnevaluatedConst<'tcx> {
2456+
ty::UnevaluatedConst { def: self.def, substs: self.substs }
24572457
}
24582458
}
24592459

2460-
impl<'tcx> Unevaluated<'tcx> {
2460+
impl<'tcx> UnevaluatedConst<'tcx> {
24612461
#[inline]
2462-
pub fn new(def: ty::WithOptConstParam<DefId>, substs: SubstsRef<'tcx>) -> Unevaluated<'tcx> {
2463-
Unevaluated { def, substs, promoted: Default::default() }
2462+
pub fn new(
2463+
def: ty::WithOptConstParam<DefId>,
2464+
substs: SubstsRef<'tcx>,
2465+
) -> UnevaluatedConst<'tcx> {
2466+
UnevaluatedConst { def, substs, promoted: Default::default() }
24642467
}
24652468
}
24662469

compiler/rustc_middle/src/mir/type_foldable.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
5151
}
5252
}
5353

54-
impl<'tcx> TypeFoldable<'tcx> for mir::Unevaluated<'tcx> {
54+
impl<'tcx> TypeFoldable<'tcx> for mir::UnevaluatedConst<'tcx> {
5555
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
5656
folder.try_fold_mir_unevaluated(self)
5757
}
5858
}
5959

60-
impl<'tcx> TypeSuperFoldable<'tcx> for mir::Unevaluated<'tcx> {
60+
impl<'tcx> TypeSuperFoldable<'tcx> for mir::UnevaluatedConst<'tcx> {
6161
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
6262
self,
6363
folder: &mut F,
6464
) -> Result<Self, F::Error> {
65-
Ok(mir::Unevaluated {
65+
Ok(mir::UnevaluatedConst {
6666
def: self.def,
6767
substs: self.substs.try_fold_with(folder)?,
6868
promoted: self.promoted,

compiler/rustc_middle/src/mir/type_visitable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ impl<'tcx, R: Idx, C: Idx> TypeVisitable<'tcx> for BitMatrix<R, C> {
99
}
1010
}
1111

12-
impl<'tcx> TypeVisitable<'tcx> for mir::Unevaluated<'tcx> {
12+
impl<'tcx> TypeVisitable<'tcx> for mir::UnevaluatedConst<'tcx> {
1313
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1414
visitor.visit_mir_unevaluated(*self)
1515
}
1616
}
1717

18-
impl<'tcx> TypeSuperVisitable<'tcx> for mir::Unevaluated<'tcx> {
18+
impl<'tcx> TypeSuperVisitable<'tcx> for mir::UnevaluatedConst<'tcx> {
1919
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
2020
self.substs.visit_with(visitor)
2121
}

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ rustc_queries! {
381381
}
382382

383383
query try_unify_abstract_consts(key:
384-
ty::ParamEnvAnd<'tcx, (ty::Unevaluated<'tcx>, ty::Unevaluated<'tcx>
384+
ty::ParamEnvAnd<'tcx, (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>
385385
)>) -> bool {
386386
desc {
387387
|tcx| "trying to unify the generic constants {} and {}",

compiler/rustc_middle/src/ty/abstract_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct AbstractConst<'tcx> {
3030
impl<'tcx> AbstractConst<'tcx> {
3131
pub fn new(
3232
tcx: TyCtxt<'tcx>,
33-
uv: ty::Unevaluated<'tcx>,
33+
uv: ty::UnevaluatedConst<'tcx>,
3434
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
3535
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
3636
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);

compiler/rustc_middle/src/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'tcx> Const<'tcx> {
7878
match Self::try_eval_lit_or_param(tcx, ty, expr) {
7979
Some(v) => v,
8080
None => tcx.mk_const(ty::ConstS {
81-
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
81+
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst {
8282
def: def.to_global(),
8383
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
8484
}),

compiler/rustc_middle/src/ty/consts/kind.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,31 @@ use super::ScalarInt;
1515
/// An unevaluated (potentially generic) constant used in the type-system.
1616
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable, Lift)]
1717
#[derive(Hash, HashStable)]
18-
pub struct Unevaluated<'tcx> {
18+
pub struct UnevaluatedConst<'tcx> {
1919
pub def: ty::WithOptConstParam<DefId>,
2020
pub substs: SubstsRef<'tcx>,
2121
}
2222

23-
impl rustc_errors::IntoDiagnosticArg for Unevaluated<'_> {
23+
impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> {
2424
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
2525
format!("{:?}", self).into_diagnostic_arg()
2626
}
2727
}
2828

29-
impl<'tcx> Unevaluated<'tcx> {
29+
impl<'tcx> UnevaluatedConst<'tcx> {
3030
#[inline]
31-
pub fn expand(self) -> mir::Unevaluated<'tcx> {
32-
mir::Unevaluated { def: self.def, substs: self.substs, promoted: None }
31+
pub fn expand(self) -> mir::UnevaluatedConst<'tcx> {
32+
mir::UnevaluatedConst { def: self.def, substs: self.substs, promoted: None }
3333
}
3434
}
3535

36-
impl<'tcx> Unevaluated<'tcx> {
36+
impl<'tcx> UnevaluatedConst<'tcx> {
3737
#[inline]
38-
pub fn new(def: ty::WithOptConstParam<DefId>, substs: SubstsRef<'tcx>) -> Unevaluated<'tcx> {
39-
Unevaluated { def, substs }
38+
pub fn new(
39+
def: ty::WithOptConstParam<DefId>,
40+
substs: SubstsRef<'tcx>,
41+
) -> UnevaluatedConst<'tcx> {
42+
UnevaluatedConst { def, substs }
4043
}
4144
}
4245

@@ -58,7 +61,7 @@ pub enum ConstKind<'tcx> {
5861

5962
/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
6063
/// variants when the code is monomorphic enough for that.
61-
Unevaluated(Unevaluated<'tcx>),
64+
Unevaluated(UnevaluatedConst<'tcx>),
6265

6366
/// Used to hold computed value.
6467
Value(ty::ValTree<'tcx>),
@@ -193,7 +196,7 @@ impl<'tcx> ConstKind<'tcx> {
193196
// FIXME(eddyb, skinny121) pass `InferCtxt` into here when it's available, so that
194197
// we can call `infcx.const_eval_resolve` which handles inference variables.
195198
let param_env_and = if param_env_and.needs_infer() {
196-
tcx.param_env(unevaluated.def.did).and(ty::Unevaluated {
199+
tcx.param_env(unevaluated.def.did).and(ty::UnevaluatedConst {
197200
def: unevaluated.def,
198201
substs: InternalSubsts::identity_for_item(tcx, unevaluated.def.did),
199202
})

compiler/rustc_middle/src/ty/flags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl FlagComputation {
3434
result.flags
3535
}
3636

37-
pub fn for_unevaluated_const(uv: ty::Unevaluated<'_>) -> TypeFlags {
37+
pub fn for_unevaluated_const(uv: ty::UnevaluatedConst<'_>) -> TypeFlags {
3838
let mut result = FlagComputation::new();
3939
result.add_unevaluated_const(uv);
4040
result.flags
@@ -313,7 +313,7 @@ impl FlagComputation {
313313
}
314314
}
315315

316-
fn add_unevaluated_const(&mut self, ct: ty::Unevaluated<'_>) {
316+
fn add_unevaluated_const(&mut self, ct: ty::UnevaluatedConst<'_>) {
317317
self.add_substs(ct.substs);
318318
self.add_flags(TypeFlags::HAS_CT_PROJECTION);
319319
}

0 commit comments

Comments
 (0)