Skip to content

Commit d914831

Browse files
committed
rustc: add more doc comments to ty::Lift and ty::with_ctxt.
1 parent 0b58fdf commit d914831

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustc/middle/ty.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,12 @@ impl<'tcx> ctxt<'tcx> {
816816
/// provided ty::ctxt<'tcx>.
817817
/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx>
818818
/// 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.
819825
pub trait Lift<'tcx> {
820826
type Lifted;
821827
fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<Self::Lifted>;
@@ -3016,6 +3022,10 @@ impl<'tcx> CommonTypes<'tcx> {
30163022
}
30173023
}
30183024

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.
30193029
pub fn with_ctxt<'tcx, F, R>(s: Session,
30203030
arenas: &'tcx CtxtArenas<'tcx>,
30213031
def_map: DefMap,

0 commit comments

Comments
 (0)