|
4 | 4 |
|
5 | 5 | pub mod tls;
|
6 | 6 |
|
| 7 | +pub use rustc_type_ir::lift::Lift; |
| 8 | + |
7 | 9 | use crate::arena::Arena;
|
8 | 10 | use crate::dep_graph::{DepGraph, DepKindStruct};
|
9 | 11 | use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
|
@@ -917,7 +919,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
917 | 919 | )
|
918 | 920 | }
|
919 | 921 |
|
920 |
| - pub fn lift<T: Lift<'tcx>>(self, value: T) -> Option<T::Lifted> { |
| 922 | + pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> { |
921 | 923 | value.lift_to_tcx(self)
|
922 | 924 | }
|
923 | 925 |
|
@@ -1524,31 +1526,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
1524 | 1526 | }
|
1525 | 1527 | }
|
1526 | 1528 |
|
1527 |
| -/// A trait implemented for all `X<'a>` types that can be safely and |
1528 |
| -/// efficiently converted to `X<'tcx>` as long as they are part of the |
1529 |
| -/// provided `TyCtxt<'tcx>`. |
1530 |
| -/// This can be done, for example, for `Ty<'tcx>` or `GenericArgsRef<'tcx>` |
1531 |
| -/// by looking them up in their respective interners. |
1532 |
| -/// |
1533 |
| -/// However, this is still not the best implementation as it does |
1534 |
| -/// need to compare the components, even for interned values. |
1535 |
| -/// It would be more efficient if `TypedArena` provided a way to |
1536 |
| -/// determine whether the address is in the allocated range. |
1537 |
| -/// |
1538 |
| -/// `None` is returned if the value or one of the components is not part |
1539 |
| -/// of the provided context. |
1540 |
| -/// For `Ty`, `None` can be returned if either the type interner doesn't |
1541 |
| -/// contain the `TyKind` key or if the address of the interned |
1542 |
| -/// pointer differs. The latter case is possible if a primitive type, |
1543 |
| -/// e.g., `()` or `u8`, was interned in a different context. |
1544 |
| -pub trait Lift<'tcx>: fmt::Debug { |
1545 |
| - type Lifted: fmt::Debug + 'tcx; |
1546 |
| - fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted>; |
1547 |
| -} |
1548 |
| - |
1549 | 1529 | macro_rules! nop_lift {
|
1550 | 1530 | ($set:ident; $ty:ty => $lifted:ty) => {
|
1551 |
| - impl<'a, 'tcx> Lift<'tcx> for $ty { |
| 1531 | + impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for $ty { |
1552 | 1532 | type Lifted = $lifted;
|
1553 | 1533 | fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
1554 | 1534 | // Assert that the set has the right type.
|
@@ -1583,7 +1563,7 @@ macro_rules! nop_lift {
|
1583 | 1563 |
|
1584 | 1564 | macro_rules! nop_list_lift {
|
1585 | 1565 | ($set:ident; $ty:ty => $lifted:ty) => {
|
1586 |
| - impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { |
| 1566 | + impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a List<$ty> { |
1587 | 1567 | type Lifted = &'tcx List<$lifted>;
|
1588 | 1568 | fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
1589 | 1569 | // Assert that the set has the right type.
|
@@ -1621,7 +1601,7 @@ nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}
|
1621 | 1601 |
|
1622 | 1602 | macro_rules! nop_slice_lift {
|
1623 | 1603 | ($ty:ty => $lifted:ty) => {
|
1624 |
| - impl<'a, 'tcx> Lift<'tcx> for &'a [$ty] { |
| 1604 | + impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a [$ty] { |
1625 | 1605 | type Lifted = &'tcx [$lifted];
|
1626 | 1606 | fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
1627 | 1607 | if self.is_empty() {
|
|
0 commit comments