@@ -621,6 +621,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
621
621
}
622
622
623
623
impl < ' 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.
624
631
pub fn moves_by_default ( & ' tcx self ,
625
632
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
626
633
param_env : ty:: ParamEnv < ' tcx > ,
@@ -629,13 +636,24 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
629
636
!tcx. at ( span) . is_copy_raw ( param_env. and ( self ) )
630
637
}
631
638
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.
632
645
pub fn is_sized ( & ' tcx self ,
633
646
tcx_at : TyCtxtAt < ' a , ' tcx , ' tcx > ,
634
647
param_env : ty:: ParamEnv < ' tcx > ) -> bool
635
648
{
636
649
tcx_at. is_sized_raw ( param_env. and ( self ) )
637
650
}
638
651
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.
639
657
pub fn is_freeze ( & ' tcx self ,
640
658
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
641
659
param_env : ty:: ParamEnv < ' tcx > ,
0 commit comments