Skip to content

Commit bea205a

Browse files
committed
Rename unevaluatedConst to AliasConst and UnevaluatedConstKind to AliasConstKind
1 parent 8c3f167 commit bea205a

38 files changed

Lines changed: 162 additions & 204 deletions

File tree

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,10 +1761,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17611761
let maybe_uneval = match constant.const_ {
17621762
Const::Ty(_, ct) => match ct.kind() {
17631763
ty::ConstKind::Unevaluated(uv) => match uv.kind {
1764-
ty::UnevaluatedConstKind::Projection { def_id }
1765-
| ty::UnevaluatedConstKind::Inherent { def_id }
1766-
| ty::UnevaluatedConstKind::Free { def_id }
1767-
| ty::UnevaluatedConstKind::Anon { def_id } => {
1764+
ty::AliasConstKind::Projection { def_id }
1765+
| ty::AliasConstKind::Inherent { def_id }
1766+
| ty::AliasConstKind::Free { def_id }
1767+
| ty::AliasConstKind::Anon { def_id } => {
17681768
Some(UnevaluatedConst { def: def_id, args: uv.args, promoted: None })
17691769
}
17701770
},

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ fn const_evaluatable_predicates_of<'tcx>(
419419
preds: FxIndexSet<(ty::Clause<'tcx>, Span)>,
420420
}
421421

422-
fn is_const_param_default(tcx: TyCtxt<'_>, kind: ty::UnevaluatedConstKind<'_>) -> bool {
423-
let ty::UnevaluatedConstKind::Anon { def_id } = kind else { return false };
422+
fn is_const_param_default(tcx: TyCtxt<'_>, kind: ty::AliasConstKind<'_>) -> bool {
423+
let ty::AliasConstKind::Anon { def_id } = kind else { return false };
424424
let Some(local) = def_id.as_local() else { return false };
425425

426426
let hir_id = tcx.local_def_id_to_hir_id(local);

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,9 +1862,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
18621862
ty::AssocTag::Const,
18631863
)?;
18641864
self.require_type_const_attribute(item_def_id, span)?;
1865-
let uv = ty::UnevaluatedConst::new(
1865+
let uv = ty::AliasConst::new(
18661866
tcx,
1867-
ty::UnevaluatedConstKind::new_from_def_id(tcx, item_def_id),
1867+
ty::AliasConstKind::new_from_def_id(tcx, item_def_id),
18681868
item_args,
18691869
);
18701870
Ok(Const::new_unevaluated(tcx, uv))
@@ -2748,11 +2748,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
27482748
let args = self.lower_generic_args_of_path_segment(span, did, segment);
27492749
ty::Const::new_unevaluated(
27502750
tcx,
2751-
ty::UnevaluatedConst::new(
2752-
tcx,
2753-
ty::UnevaluatedConstKind::new_from_def_id(tcx, did),
2754-
args,
2755-
),
2751+
ty::AliasConst::new(tcx, ty::AliasConstKind::new_from_def_id(tcx, did), args),
27562752
)
27572753
}
27582754
Res::Def(kind @ DefKind::Ctor(ctor_of, CtorKind::Const), did) => {
@@ -2905,9 +2901,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
29052901
Some(v) => v,
29062902
None => ty::Const::new_unevaluated(
29072903
tcx,
2908-
ty::UnevaluatedConst::new(
2904+
ty::AliasConst::new(
29092905
tcx,
2910-
ty::UnevaluatedConstKind::Anon { def_id: anon.def_id.to_def_id() },
2906+
ty::AliasConstKind::Anon { def_id: anon.def_id.to_def_id() },
29112907
ty::GenericArgs::identity_for_item(tcx, anon.def_id.to_def_id()),
29122908
),
29132909
),

compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,14 +760,14 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
760760
self.generalize_alias_term(uv.into()).map(|v| v.expect_const())
761761
}
762762
_ => {
763-
let ty::UnevaluatedConst { kind, args, .. } = uv;
763+
let ty::AliasConst { kind, args, .. } = uv;
764764
let args = self.relate_with_variance(
765765
ty::Invariant,
766766
ty::VarianceDiagInfo::default(),
767767
args,
768768
args,
769769
)?;
770-
Ok(ty::Const::new_unevaluated(tcx, ty::UnevaluatedConst::new(tcx, kind, args)))
770+
Ok(ty::Const::new_unevaluated(tcx, ty::AliasConst::new(tcx, kind, args)))
771771
}
772772
},
773773
ty::ConstKind::Placeholder(placeholder) => {

compiler/rustc_middle/src/mir/consts.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,13 +467,9 @@ pub struct UnevaluatedConst<'tcx> {
467467

468468
impl<'tcx> UnevaluatedConst<'tcx> {
469469
#[inline]
470-
pub fn shrink(self, tcx: TyCtxt<'tcx>) -> ty::UnevaluatedConst<'tcx> {
470+
pub fn shrink(self, tcx: TyCtxt<'tcx>) -> ty::AliasConst<'tcx> {
471471
assert_eq!(self.promoted, None);
472-
ty::UnevaluatedConst::new(
473-
tcx,
474-
ty::UnevaluatedConstKind::new_from_def_id(tcx, self.def),
475-
self.args,
476-
)
472+
ty::AliasConst::new(tcx, ty::AliasConstKind::new_from_def_id(tcx, self.def), self.args)
477473
}
478474
}
479475

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> {
9090
pub fn const_eval_resolve_for_typeck(
9191
self,
9292
typing_env: ty::TypingEnv<'tcx>,
93-
ct: ty::UnevaluatedConst<'tcx>,
93+
ct: ty::AliasConst<'tcx>,
9494
span: Span,
9595
) -> ConstToValTreeResult<'tcx> {
9696
// Cannot resolve `Unevaluated` constants that contain inference
@@ -104,10 +104,10 @@ impl<'tcx> TyCtxt<'tcx> {
104104
}
105105

106106
let def_id = match ct.kind {
107-
ty::UnevaluatedConstKind::Projection { def_id }
108-
| ty::UnevaluatedConstKind::Inherent { def_id }
109-
| ty::UnevaluatedConstKind::Free { def_id }
110-
| ty::UnevaluatedConstKind::Anon { def_id } => def_id,
107+
ty::AliasConstKind::Projection { def_id }
108+
| ty::AliasConstKind::Inherent { def_id }
109+
| ty::AliasConstKind::Free { def_id }
110+
| ty::AliasConstKind::Anon { def_id } => def_id,
111111
};
112112

113113
let cid = match ty::Instance::try_resolve(self, typing_env, def_id, ct.args) {

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,12 +1493,10 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
14931493
ty::ConstKind::Param(p) => format!("ty::Param({p})"),
14941494
ty::ConstKind::Unevaluated(uv) => {
14951495
let kind = match uv.kind {
1496-
ty::UnevaluatedConstKind::Projection { def_id }
1497-
| ty::UnevaluatedConstKind::Inherent { def_id }
1498-
| ty::UnevaluatedConstKind::Free { def_id }
1499-
| ty::UnevaluatedConstKind::Anon { def_id } => {
1500-
self.tcx.def_path_str(def_id)
1501-
}
1496+
ty::AliasConstKind::Projection { def_id }
1497+
| ty::AliasConstKind::Inherent { def_id }
1498+
| ty::AliasConstKind::Free { def_id }
1499+
| ty::AliasConstKind::Anon { def_id } => self.tcx.def_path_str(def_id),
15021500
};
15031501
format!("ty::Unevaluated({}, {:?})", kind, uv.args)
15041502
}

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed};
2121
pub use valtree::*;
2222

2323
pub type ConstKind<'tcx> = ir::ConstKind<TyCtxt<'tcx>>;
24-
pub type UnevaluatedConst<'tcx> = ir::UnevaluatedConst<TyCtxt<'tcx>>;
25-
pub type UnevaluatedConstKind<'tcx> = ir::UnevaluatedConstKind<TyCtxt<'tcx>>;
24+
pub type AliasConst<'tcx> = ir::AliasConst<TyCtxt<'tcx>>;
25+
pub type AliasConstKind<'tcx> = ir::AliasConstKind<TyCtxt<'tcx>>;
2626

2727
#[cfg(target_pointer_width = "64")]
2828
rustc_data_structures::static_assert_size!(ConstKind<'_>, 32);
@@ -107,7 +107,7 @@ impl<'tcx> Const<'tcx> {
107107
}
108108

109109
#[inline]
110-
pub fn new_unevaluated(tcx: TyCtxt<'tcx>, uv: ty::UnevaluatedConst<'tcx>) -> Const<'tcx> {
110+
pub fn new_unevaluated(tcx: TyCtxt<'tcx>, uv: ty::AliasConst<'tcx>) -> Const<'tcx> {
111111
Const::new(tcx, ty::ConstKind::Unevaluated(uv))
112112
}
113113

@@ -190,7 +190,7 @@ impl<'tcx> rustc_type_ir::inherent::Const<TyCtxt<'tcx>> for Const<'tcx> {
190190
Const::new_placeholder(tcx, placeholder)
191191
}
192192

193-
fn new_unevaluated(interner: TyCtxt<'tcx>, uv: ty::UnevaluatedConst<'tcx>) -> Self {
193+
fn new_unevaluated(interner: TyCtxt<'tcx>, uv: ty::AliasConst<'tcx>) -> Self {
194194
Const::new_unevaluated(interner, uv)
195195
}
196196

compiler/rustc_middle/src/ty/context/impl_interner.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,20 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
208208
self.adt_def(adt_def_id)
209209
}
210210

211-
fn unevaluated_const_kind_from_def_id(
212-
self,
213-
def_id: Self::DefId,
214-
) -> ty::UnevaluatedConstKind<'tcx> {
211+
fn alias_const_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasConstKind<'tcx> {
215212
match self.def_kind(def_id) {
216213
DefKind::AssocConst { .. } => {
217214
if let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id)) {
218-
ty::UnevaluatedConstKind::Inherent { def_id }
215+
ty::AliasConstKind::Inherent { def_id }
219216
} else {
220-
ty::UnevaluatedConstKind::Projection { def_id }
217+
ty::AliasConstKind::Projection { def_id }
221218
}
222219
}
223-
DefKind::Const { .. } => ty::UnevaluatedConstKind::Free { def_id },
220+
DefKind::Const { .. } => ty::AliasConstKind::Free { def_id },
224221
DefKind::AnonConst | DefKind::InlineConst | DefKind::Ctor(_, CtorKind::Const) => {
225-
ty::UnevaluatedConstKind::Anon { def_id }
222+
ty::AliasConstKind::Anon { def_id }
226223
}
227-
kind => bug!("unexpected DefKind in UnevaluatedConst: {kind:?}"),
224+
kind => bug!("unexpected DefKind in AliasConst: {kind:?}"),
228225
}
229226
}
230227

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ pub use self::closure::{
7777
place_to_string_for_capture,
7878
};
7979
pub use self::consts::{
80-
AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult, Expr, ExprKind,
81-
LitToConstInput, ScalarInt, SimdAlign, UnevaluatedConst, UnevaluatedConstKind, ValTree,
82-
ValTreeKindExt, Value, const_lit_matches_ty,
80+
AliasConst, AliasConstKind, AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult,
81+
Expr, ExprKind, LitToConstInput, ScalarInt, SimdAlign, ValTree, ValTreeKindExt, Value,
82+
const_lit_matches_ty,
8383
};
8484
pub use self::context::{
8585
CtxtInterners, CurrentGcx, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,

0 commit comments

Comments
 (0)