1
Fork 0

Remove rich UserTypeProjection projections in SMIR

It's not clear to me (klinvill) that UserTypeProjections are produced
anymore with the removal of type ascriptions as per
https://github.com/rust-lang/rfcs/pull/3307. Furthermore, it's not clear
to me which variants of ProjectionElem could appear in such projections.
For these reasons, I'm reverting projections in UserTypeProjections to
simple strings until I can get more clarity on UserTypeProjections.
This commit is contained in:
Kirby Linvill 2023-11-09 20:34:30 -07:00
parent 30d6733eb3
commit 2e70d95cdb
No known key found for this signature in database
GPG key ID: E304CE3F028E6E3F
3 changed files with 16 additions and 49 deletions

View file

@ -691,7 +691,7 @@ impl<'tcx> Stable<'tcx> for mir::Place<'tcx> {
}
impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> {
type T = stable_mir::mir::ProjectionElem<stable_mir::mir::Local, stable_mir::ty::Ty>;
type T = stable_mir::mir::ProjectionElem;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::ProjectionElem::*;
match self {
@ -722,40 +722,8 @@ impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> {
impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
type T = stable_mir::mir::UserTypeProjection;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
UserTypeProjection {
base: self.base.as_usize(),
projection: self.projs.iter().map(|e| e.stable(tables)).collect(),
}
}
}
// ProjectionKind is nearly identical to PlaceElem, except its generic arguments are units. We
// therefore don't need to resolve any arguments with the generic types.
impl<'tcx> Stable<'tcx> for mir::ProjectionKind {
type T = stable_mir::mir::ProjectionElem<(), ()>;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::ProjectionElem::*;
match self {
Deref => stable_mir::mir::ProjectionElem::Deref,
Field(idx, ty) => stable_mir::mir::ProjectionElem::Field(idx.stable(tables), *ty),
Index(local) => stable_mir::mir::ProjectionElem::Index(*local),
ConstantIndex { offset, min_length, from_end } => {
stable_mir::mir::ProjectionElem::ConstantIndex {
offset: *offset,
min_length: *min_length,
from_end: *from_end,
}
}
Subslice { from, to, from_end } => stable_mir::mir::ProjectionElem::Subslice {
from: *from,
to: *to,
from_end: *from_end,
},
Downcast(_, idx) => stable_mir::mir::ProjectionElem::Downcast(idx.stable(tables)),
OpaqueCast(ty) => stable_mir::mir::ProjectionElem::OpaqueCast(*ty),
Subtype(ty) => stable_mir::mir::ProjectionElem::Subtype(*ty),
}
fn stable(&self, _tables: &mut Tables<'tcx>) -> Self::T {
UserTypeProjection { base: self.base.as_usize(), projection: format!("{:?}", self.projs) }
}
}