@@ -621,6 +621,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
621621}
622622
623623impl < ' a , ' tcx > ty:: TyS < ' tcx > {
624+ /// Checks whether values of this type `T` are *moved* or *copied*
625+ /// when referenced -- this amounts to a check for whether `T:
626+ /// Copy`, but note that we **don't** consider lifetimes when
627+ /// doing this check. This means that we may generate MIR which
628+ /// does copies even when the type actually doesn't satisfy the
629+ /// full requirements for the `Copy` trait (cc #29149) -- this
630+ /// winds up being reported as an error during NLL borrow check.
624631 pub fn moves_by_default ( & ' tcx self ,
625632 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
626633 param_env : ty:: ParamEnv < ' tcx > ,
@@ -629,13 +636,24 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
629636 !tcx. at ( span) . is_copy_raw ( param_env. and ( self ) )
630637 }
631638
639+ /// Checks whether values of this type `T` have a size known at
640+ /// compile time (i.e., whether `T: Sized`). Lifetimes are ignored
641+ /// for the purposes of this check, so it can be an
642+ /// over-approximation in generic contexts, where one can have
643+ /// strange rules like `<T as Foo<'static>>::Bar: Sized` that
644+ /// actually carry lifetime requirements.
632645 pub fn is_sized ( & ' tcx self ,
633646 tcx_at : TyCtxtAt < ' a , ' tcx , ' tcx > ,
634647 param_env : ty:: ParamEnv < ' tcx > ) -> bool
635648 {
636649 tcx_at. is_sized_raw ( param_env. and ( self ) )
637650 }
638651
652+ /// Checks whether values of this type `T` implement the `Freeze`
653+ /// trait -- frozen types are those that do not contain a
654+ /// `UnsafeCell` anywhere. This is a language concept used to
655+ /// determine how to handle `static` values, the trait itself is
656+ /// not exposed to end users.
639657 pub fn is_freeze ( & ' tcx self ,
640658 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
641659 param_env : ty:: ParamEnv < ' tcx > ,
0 commit comments