Skip to content

Commit 627fa80

Browse files
committed
Add types to all constants
1 parent a370f1b commit 627fa80

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1136,14 +1136,14 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11361136
ty::PlaceholderCt(_) => unimplemented!(),
11371137
ty::Unevaluated(uv) => {
11381138
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
1139-
ty: tables.intern_ty(self.ty()),
11401139
def: tables.const_def(uv.def),
11411140
args: uv.args.stable(tables),
11421141
promoted: None,
11431142
})
11441143
}
11451144
ty::ExprCt(_) => unimplemented!(),
11461145
},
1146+
ty: tables.intern_ty(self.ty()),
11471147
}
11481148
}
11491149
}
@@ -1224,17 +1224,18 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::ConstantKind<'tcx> {
12241224
ConstantKind::Unevaluated(unev_const, ty) => stable_mir::ty::Const {
12251225
literal: stable_mir::ty::ConstantKind::Unevaluated(
12261226
stable_mir::ty::UnevaluatedConst {
1227-
ty: tables.intern_ty(ty),
12281227
def: tables.const_def(unev_const.def),
12291228
args: unev_const.args.stable(tables),
12301229
promoted: unev_const.promoted.map(|u| u.as_u32()),
12311230
},
12321231
),
1232+
ty: tables.intern_ty(ty),
12331233
},
12341234
ConstantKind::Val(val, ty) => stable_mir::ty::Const {
12351235
literal: stable_mir::ty::ConstantKind::Allocated(alloc::new_allocation(
12361236
ty, val, tables,
12371237
)),
1238+
ty: tables.intern_ty(ty),
12381239
},
12391240
}
12401241
}

compiler/rustc_smir/src/stable_mir/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl Foldable for Const {
5151
super::ty::ConstantKind::Unevaluated(uv) => *uv = uv.fold(folder)?,
5252
super::ty::ConstantKind::ParamCt(param) => *param = param.fold(folder)?,
5353
}
54+
this.ty = this.ty.fold(folder)?;
5455
ControlFlow::Continue(this)
5556
}
5657
}
@@ -69,9 +70,8 @@ impl Foldable for Allocation {
6970

7071
impl Foldable for UnevaluatedConst {
7172
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
72-
let UnevaluatedConst { ty, def, args, promoted } = self;
73+
let UnevaluatedConst { def, args, promoted } = self;
7374
ControlFlow::Continue(UnevaluatedConst {
74-
ty: ty.fold(folder)?,
7575
def: def.fold(folder)?,
7676
args: args.fold(folder)?,
7777
promoted: promoted.fold(folder)?,

compiler/rustc_smir/src/stable_mir/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl From<TyKind> for Ty {
1919
#[derive(Debug, Clone)]
2020
pub struct Const {
2121
pub literal: ConstantKind,
22+
pub ty: Ty,
2223
}
2324

2425
type Ident = Opaque;
@@ -298,7 +299,6 @@ pub enum ConstantKind {
298299

299300
#[derive(Clone, Debug)]
300301
pub struct UnevaluatedConst {
301-
pub ty: Ty,
302302
pub def: ConstDef,
303303
pub args: GenericArgs,
304304
pub promoted: Option<Promoted>,

compiler/rustc_smir/src/stable_mir/visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ impl Visitable for Const {
4747
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor),
4848
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor),
4949
super::ty::ConstantKind::ParamCt(param) => param.visit(visitor),
50-
}
50+
}?;
51+
self.ty.visit(visitor)
5152
}
5253
}
5354

@@ -65,8 +66,7 @@ impl Visitable for Allocation {
6566

6667
impl Visitable for UnevaluatedConst {
6768
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
68-
let UnevaluatedConst { ty, def, args, promoted } = self;
69-
ty.visit(visitor)?;
69+
let UnevaluatedConst { def, args, promoted } = self;
7070
def.visit(visitor)?;
7171
args.visit(visitor)?;
7272
promoted.visit(visitor)

0 commit comments

Comments
 (0)