Skip to content

Commit c909b6d

Browse files
committed
add comment to Lift impls
1 parent 758f4e7 commit c909b6d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/rustc_middle/src/ty/context.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,8 @@ macro_rules! nop_lift {
16551655
type Lifted = $lifted;
16561656
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
16571657
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self.0.0)) {
1658+
// SAFETY: `self` is interned and therefore valid
1659+
// for the entire lifetime of the `TyCtxt`.
16581660
Some(unsafe { mem::transmute(self) })
16591661
} else {
16601662
None
@@ -1674,7 +1676,9 @@ impl<'a, 'tcx> Lift<'tcx> for &'a List<Ty<'a>> {
16741676
return Some(List::empty());
16751677
}
16761678
if tcx.interners.substs.contains_pointer_to(&InternedInSet(self.as_substs())) {
1677-
Some(unsafe { mem::transmute(self) })
1679+
// SAFETY: `self` is interned and therefore valid
1680+
// for the entire lifetime of the `TyCtxt`.
1681+
Some(unsafe { mem::transmute::<&'a List<Ty<'a>>, &'tcx List<Ty<'tcx>>>(self) })
16781682
} else {
16791683
None
16801684
}

0 commit comments

Comments
 (0)