|
10 | 10 | use crate::rustc_internal::{self, opaque};
|
11 | 11 | use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
12 | 12 | use crate::stable_mir::ty::{
|
13 |
| - EarlyBoundRegion, FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy, |
| 13 | + BoundRegion, EarlyBoundRegion, FloatTy, FreeRegion, GenericParamDef, IntTy, Movability, Region, |
| 14 | + RigidTy, Span, TyKind, UintTy, |
14 | 15 | };
|
15 | 16 | use crate::stable_mir::{self, CompilerError, Context};
|
16 | 17 | use rustc_hir as hir;
|
@@ -1505,29 +1506,43 @@ impl<'tcx> Stable<'tcx> for ty::ImplPolarity {
|
1505 | 1506 | impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
|
1506 | 1507 | type T = stable_mir::ty::Region;
|
1507 | 1508 |
|
1508 |
| - fn stable(&self, _: &mut Tables<'tcx>) -> Self::T { |
1509 |
| - // FIXME: add a real implementation of stable regions |
1510 |
| - opaque(self) |
| 1509 | + fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { |
| 1510 | + Region { kind: self.kind().stable(tables) } |
1511 | 1511 | }
|
1512 | 1512 | }
|
1513 | 1513 |
|
1514 | 1514 | impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
1515 | 1515 | type T = stable_mir::ty::RegionKind;
|
1516 | 1516 |
|
1517 | 1517 | fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
| 1518 | + use crate::stable_mir::ty::RegionKind; |
1518 | 1519 | match self {
|
1519 | 1520 | ty::ReEarlyBound(early_reg) => RegionKind::ReEarlyBound(EarlyBoundRegion {
|
1520 | 1521 | def_id: tables.region_def(early_reg.def_id),
|
1521 | 1522 | index: early_reg.index,
|
1522 | 1523 | name: early_reg.name.to_string(),
|
1523 | 1524 | }),
|
1524 |
| - ty::ReLateBound(_, _) => todo!(), |
1525 |
| - ty::ReFree(_) => todo!(), |
1526 |
| - ty::ReStatic => todo!(), |
1527 |
| - ty::ReVar(_) => todo!(), |
1528 |
| - ty::RePlaceholder(_) => todo!(), |
1529 |
| - ty::ReErased => todo!(), |
1530 |
| - ty::ReError(_) => todo!(), |
| 1525 | + ty::ReLateBound(db_index, bound_reg) => RegionKind::ReLateBound( |
| 1526 | + db_index.as_u32(), |
| 1527 | + BoundRegion { var: bound_reg.var.as_u32(), kind: bound_reg.kind.stable(tables) }, |
| 1528 | + ), |
| 1529 | + ty::ReFree(free_reg) => RegionKind::ReFree(FreeRegion { |
| 1530 | + scope: tables.region_def(free_reg.scope), |
| 1531 | + bound_region: free_reg.bound_region.stable(tables), |
| 1532 | + }), |
| 1533 | + ty::ReStatic => RegionKind::ReStatic, |
| 1534 | + ty::ReVar(vid_reg) => RegionKind::ReVar(vid_reg.as_u32()), |
| 1535 | + ty::RePlaceholder(place_holder) => { |
| 1536 | + RegionKind::RePlaceholder(stable_mir::ty::Placeholder { |
| 1537 | + universe: place_holder.universe.as_u32(), |
| 1538 | + bound: BoundRegion { |
| 1539 | + var: place_holder.bound.var.as_u32(), |
| 1540 | + kind: place_holder.bound.kind.stable(tables), |
| 1541 | + }, |
| 1542 | + }) |
| 1543 | + } |
| 1544 | + ty::ReErased => RegionKind::ReErased, |
| 1545 | + ty::ReError(_) => RegionKind::ReError(()), |
1531 | 1546 | }
|
1532 | 1547 | }
|
1533 | 1548 | }
|
|
0 commit comments