@@ -816,6 +816,12 @@ impl<'tcx> ctxt<'tcx> {
816
816
/// provided ty::ctxt<'tcx>.
817
817
/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx>
818
818
/// by looking them up in their respective interners.
819
+ /// None is returned if the value or one of the components is not part
820
+ /// of the provided context.
821
+ /// For Ty, None can be returned if either the type interner doesn't
822
+ /// contain the TypeVariants key or if the address of the interned
823
+ /// pointer differs. The latter case is possible if a primitive type,
824
+ /// e.g. `()` or `u8`, was interned in a different context.
819
825
pub trait Lift < ' tcx > {
820
826
type Lifted ;
821
827
fn lift_to_tcx ( & self , tcx : & ctxt < ' tcx > ) -> Option < Self :: Lifted > ;
@@ -3016,6 +3022,10 @@ impl<'tcx> CommonTypes<'tcx> {
3016
3022
}
3017
3023
}
3018
3024
3025
+ /// Create a type context and call the closure with a `&ty::ctxt` reference
3026
+ /// to the context. The closure enforces that the type context and any interned
3027
+ /// value (types, substs, etc.) can only be used while `ty::tls` has a valid
3028
+ /// reference to the context, to allow formatting values that need it.
3019
3029
pub fn with_ctxt < ' tcx , F , R > ( s : Session ,
3020
3030
arenas : & ' tcx CtxtArenas < ' tcx > ,
3021
3031
def_map : DefMap ,
0 commit comments