Skip to content

Commit 0f16bd3

Browse files
committed
Auto merge of #113659 - ericmarkmartin:smir-refs-and-ptrs, r=spastorino
Add ty convs for smir refs and ptrs r? `@spastorino`
2 parents 6b9236e + c8ee46b commit 0f16bd3

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ impl<'tcx> Tables<'tcx> {
119119
TyKind::RigidTy(RigidTy::Array(self.intern_ty(*ty), opaque(constant)))
120120
}
121121
ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(self.intern_ty(*ty))),
122-
ty::RawPtr(_) => todo!(),
123-
ty::Ref(_, _, _) => todo!(),
122+
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
123+
TyKind::RigidTy(RigidTy::RawPtr(self.intern_ty(*ty), mutbl.stable()))
124+
}
125+
ty::Ref(region, ty, mutbl) => {
126+
TyKind::RigidTy(RigidTy::Ref(opaque(region), self.intern_ty(*ty), mutbl.stable()))
127+
}
124128
ty::FnDef(_, _) => todo!(),
125129
ty::FnPtr(_) => todo!(),
126130
ty::Dynamic(_, _, _) => todo!(),

compiler/rustc_smir/src/stable_mir/mir/body.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::rustc_internal::Opaque;
1+
use crate::stable_mir::ty::Region;
22
use crate::stable_mir::{self, ty::Ty};
33

44
#[derive(Clone, Debug)]
@@ -137,8 +137,6 @@ pub enum Statement {
137137
Nop,
138138
}
139139

140-
type Region = Opaque;
141-
142140
// FIXME this is incomplete
143141
#[derive(Clone, Debug)]
144142
pub enum Rvalue {

compiler/rustc_smir/src/stable_mir/ty.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{with, DefId};
1+
use super::{mir::Mutability, with, DefId};
22
use crate::rustc_internal::Opaque;
33

44
#[derive(Copy, Clone, Debug)]
@@ -11,7 +11,7 @@ impl Ty {
1111
}
1212

1313
type Const = Opaque;
14-
type Region = Opaque;
14+
pub(crate) type Region = Opaque;
1515

1616
#[derive(Clone, Debug)]
1717
pub enum TyKind {
@@ -29,6 +29,8 @@ pub enum RigidTy {
2929
Str,
3030
Array(Ty, Const),
3131
Slice(Ty),
32+
RawPtr(Ty, Mutability),
33+
Ref(Region, Ty, Mutability),
3234
Tuple(Vec<Ty>),
3335
}
3436

0 commit comments

Comments
 (0)