Skip to content

Commit 5a129d1

Browse files
committed
Add types to all constants
1 parent a43ac06 commit 5a129d1

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,14 +1130,14 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11301130
ty::PlaceholderCt(_) => unimplemented!(),
11311131
ty::Unevaluated(uv) => {
11321132
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
1133-
ty: tables.intern_ty(self.ty()),
11341133
def: tables.const_def(uv.def),
11351134
args: uv.args.stable(tables),
11361135
promoted: None,
11371136
})
11381137
}
11391138
ty::ExprCt(_) => unimplemented!(),
11401139
},
1140+
ty: tables.intern_ty(self.ty()),
11411141
}
11421142
}
11431143
}
@@ -1218,17 +1218,18 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::ConstantKind<'tcx> {
12181218
ConstantKind::Unevaluated(unev_const, ty) => stable_mir::ty::Const {
12191219
literal: stable_mir::ty::ConstantKind::Unevaluated(
12201220
stable_mir::ty::UnevaluatedConst {
1221-
ty: tables.intern_ty(ty),
12221221
def: tables.const_def(unev_const.def),
12231222
args: unev_const.args.stable(tables),
12241223
promoted: unev_const.promoted.map(|u| u.as_u32()),
12251224
},
12261225
),
1226+
ty: tables.intern_ty(ty),
12271227
},
12281228
ConstantKind::Val(val, ty) => stable_mir::ty::Const {
12291229
literal: stable_mir::ty::ConstantKind::Allocated(alloc::new_allocation(
12301230
ty, val, tables,
12311231
)),
1232+
ty: tables.intern_ty(ty),
12321233
},
12331234
}
12341235
}

compiler/rustc_smir/src/stable_mir/fold.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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)