|
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;
|
@@ -1508,29 +1509,43 @@ impl<'tcx> Stable<'tcx> for ty::ImplPolarity {
|
1508 | 1509 | impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
|
1509 | 1510 | type T = stable_mir::ty::Region;
|
1510 | 1511 |
|
1511 |
| - fn stable(&self, _: &mut Tables<'tcx>) -> Self::T { |
1512 |
| - // FIXME: add a real implementation of stable regions |
1513 |
| - opaque(self) |
| 1512 | + fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { |
| 1513 | + Region { kind: self.kind().stable(tables) } |
1514 | 1514 | }
|
1515 | 1515 | }
|
1516 | 1516 |
|
1517 | 1517 | impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
1518 | 1518 | type T = stable_mir::ty::RegionKind;
|
1519 | 1519 |
|
1520 | 1520 | fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
| 1521 | + use crate::stable_mir::ty::RegionKind; |
1521 | 1522 | match self {
|
1522 | 1523 | ty::ReEarlyBound(early_reg) => RegionKind::ReEarlyBound(EarlyBoundRegion {
|
1523 | 1524 | def_id: tables.region_def(early_reg.def_id),
|
1524 | 1525 | index: early_reg.index,
|
1525 | 1526 | name: early_reg.name.to_string(),
|
1526 | 1527 | }),
|
1527 |
| - ty::ReLateBound(_, _) => todo!(), |
1528 |
| - ty::ReFree(_) => todo!(), |
1529 |
| - ty::ReStatic => todo!(), |
1530 |
| - ty::ReVar(_) => todo!(), |
1531 |
| - ty::RePlaceholder(_) => todo!(), |
1532 |
| - ty::ReErased => todo!(), |
1533 |
| - ty::ReError(_) => todo!(), |
| 1528 | + ty::ReLateBound(db_index, bound_reg) => RegionKind::ReLateBound( |
| 1529 | + db_index.as_u32(), |
| 1530 | + BoundRegion { var: bound_reg.var.as_u32(), kind: bound_reg.kind.stable(tables) }, |
| 1531 | + ), |
| 1532 | + ty::ReFree(free_reg) => RegionKind::ReFree(FreeRegion { |
| 1533 | + scope: tables.region_def(free_reg.scope), |
| 1534 | + bound_region: free_reg.bound_region.stable(tables), |
| 1535 | + }), |
| 1536 | + ty::ReStatic => RegionKind::ReStatic, |
| 1537 | + ty::ReVar(vid_reg) => RegionKind::ReVar(vid_reg.as_u32()), |
| 1538 | + ty::RePlaceholder(place_holder) => { |
| 1539 | + RegionKind::RePlaceholder(stable_mir::ty::Placeholder { |
| 1540 | + universe: place_holder.universe.as_u32(), |
| 1541 | + bound: BoundRegion { |
| 1542 | + var: place_holder.bound.var.as_u32(), |
| 1543 | + kind: place_holder.bound.kind.stable(tables), |
| 1544 | + }, |
| 1545 | + }) |
| 1546 | + } |
| 1547 | + ty::ReErased => RegionKind::ReErased, |
| 1548 | + ty::ReError(_) => RegionKind::ReError(()), |
1534 | 1549 | }
|
1535 | 1550 | }
|
1536 | 1551 | }
|
|
0 commit comments