@@ -79,12 +79,11 @@ use std::fmt;
7979use std:: hash:: { Hash , Hasher } ;
8080use rustc_data_structures:: fx:: FxIndexMap ;
8181use std:: rc:: Rc ;
82- use crate :: util:: nodemap:: ItemLocalSet ;
8382
8483#[ derive( Clone , Debug , PartialEq ) ]
8584pub enum Categorization < ' tcx > {
86- Rvalue ( ty :: Region < ' tcx > ) , // temporary val, argument is its scope
87- ThreadLocal ( ty :: Region < ' tcx > ) , // value that cannot move, but still restricted in scope
85+ Rvalue , // temporary val
86+ ThreadLocal , // value that cannot move, but still restricted in scope
8887 StaticItem ,
8988 Upvar ( Upvar ) , // upvar referenced by closure env
9089 Local ( hir:: HirId ) , // local variable
@@ -219,7 +218,6 @@ pub struct MemCategorizationContext<'a, 'tcx> {
219218 pub upvars : Option < & ' tcx FxIndexMap < hir:: HirId , hir:: Upvar > > ,
220219 pub region_scope_tree : & ' a region:: ScopeTree ,
221220 pub tables : & ' a ty:: TypeckTables < ' tcx > ,
222- rvalue_promotable_map : Option < & ' tcx ItemLocalSet > ,
223221 infcx : Option < & ' a InferCtxt < ' a , ' tcx > > ,
224222}
225223
@@ -335,15 +333,13 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
335333 body_owner : DefId ,
336334 region_scope_tree : & ' a region:: ScopeTree ,
337335 tables : & ' a ty:: TypeckTables < ' tcx > ,
338- rvalue_promotable_map : Option < & ' tcx ItemLocalSet > ,
339336 ) -> MemCategorizationContext < ' a , ' tcx > {
340337 MemCategorizationContext {
341338 tcx,
342339 body_owner,
343340 upvars : tcx. upvars ( body_owner) ,
344341 region_scope_tree,
345342 tables,
346- rvalue_promotable_map,
347343 infcx : None ,
348344 param_env,
349345 }
@@ -369,19 +365,12 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
369365 ) -> MemCategorizationContext < ' a , ' tcx > {
370366 let tcx = infcx. tcx ;
371367
372- // Subtle: we can't do rvalue promotion analysis until the
373- // typeck phase is complete, which means that you can't trust
374- // the rvalue lifetimes that result, but that's ok, since we
375- // don't need to know those during type inference.
376- let rvalue_promotable_map = None ;
377-
378368 MemCategorizationContext {
379369 tcx,
380370 body_owner,
381371 upvars : tcx. upvars ( body_owner) ,
382372 region_scope_tree,
383373 tables,
384- rvalue_promotable_map,
385374 infcx : Some ( infcx) ,
386375 param_env,
387376 }
@@ -664,8 +653,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
664653 . any ( |attr| attr. check_name ( sym:: thread_local) ) ;
665654
666655 let cat = if is_thread_local {
667- let re = self . temporary_scope ( hir_id. local_id ) ;
668- Categorization :: ThreadLocal ( re)
656+ Categorization :: ThreadLocal
669657 } else {
670658 Categorization :: StaticItem
671659 } ;
@@ -876,16 +864,6 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
876864 ret
877865 }
878866
879- /// Returns the lifetime of a temporary created by expr with id `id`.
880- /// This could be `'static` if `id` is part of a constant expression.
881- pub fn temporary_scope ( & self , id : hir:: ItemLocalId ) -> ty:: Region < ' tcx > {
882- let scope = self . region_scope_tree . temporary_scope ( id) ;
883- self . tcx . mk_region ( match scope {
884- Some ( scope) => ty:: ReScope ( scope) ,
885- None => ty:: ReStatic
886- } )
887- }
888-
889867 pub fn cat_rvalue_node ( & self ,
890868 hir_id : hir:: HirId ,
891869 span : Span ,
@@ -894,41 +872,19 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
894872 debug ! ( "cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})" ,
895873 hir_id, span, expr_ty) ;
896874
897- let promotable = self . rvalue_promotable_map . as_ref ( ) . map ( |m| m. contains ( & hir_id. local_id ) )
898- . unwrap_or ( false ) ;
899-
900- debug ! ( "cat_rvalue_node: promotable = {:?}" , promotable) ;
901-
902- // Always promote `[T; 0]` (even when e.g., borrowed mutably).
903- let promotable = match expr_ty. kind {
904- ty:: Array ( _, len) if len. try_eval_usize ( self . tcx , self . param_env ) == Some ( 0 ) => true ,
905- _ => promotable,
906- } ;
907-
908- debug ! ( "cat_rvalue_node: promotable = {:?} (2)" , promotable) ;
909-
910- // Compute maximum lifetime of this rvalue. This is 'static if
911- // we can promote to a constant, otherwise equal to enclosing temp
912- // lifetime.
913- let re = if promotable {
914- self . tcx . lifetimes . re_static
915- } else {
916- self . temporary_scope ( hir_id. local_id )
917- } ;
918- let ret = self . cat_rvalue ( hir_id, span, re, expr_ty) ;
875+ let ret = self . cat_rvalue ( hir_id, span, expr_ty) ;
919876 debug ! ( "cat_rvalue_node ret {:?}" , ret) ;
920877 ret
921878 }
922879
923880 pub fn cat_rvalue ( & self ,
924881 cmt_hir_id : hir:: HirId ,
925882 span : Span ,
926- temp_scope : ty:: Region < ' tcx > ,
927883 expr_ty : Ty < ' tcx > ) -> cmt_ < ' tcx > {
928884 let ret = cmt_ {
929885 hir_id : cmt_hir_id,
930886 span : span,
931- cat : Categorization :: Rvalue ( temp_scope ) ,
887+ cat : Categorization :: Rvalue ,
932888 mutbl : McDeclared ,
933889 ty : expr_ty,
934890 note : NoteNone
@@ -1376,9 +1332,9 @@ impl<'tcx> cmt_<'tcx> {
13761332 //! determines how long the value in `self` remains live.
13771333
13781334 match self . cat {
1379- Categorization :: Rvalue ( .. ) |
1335+ Categorization :: Rvalue |
13801336 Categorization :: StaticItem |
1381- Categorization :: ThreadLocal ( .. ) |
1337+ Categorization :: ThreadLocal |
13821338 Categorization :: Local ( ..) |
13831339 Categorization :: Deref ( _, UnsafePtr ( ..) ) |
13841340 Categorization :: Deref ( _, BorrowedPtr ( ..) ) |
@@ -1409,8 +1365,8 @@ impl<'tcx> cmt_<'tcx> {
14091365 b. freely_aliasable ( )
14101366 }
14111367
1412- Categorization :: Rvalue ( .. ) |
1413- Categorization :: ThreadLocal ( .. ) |
1368+ Categorization :: Rvalue |
1369+ Categorization :: ThreadLocal |
14141370 Categorization :: Local ( ..) |
14151371 Categorization :: Upvar ( ..) |
14161372 Categorization :: Deref ( _, UnsafePtr ( ..) ) => { // yes, it's aliasable, but...
@@ -1457,10 +1413,10 @@ impl<'tcx> cmt_<'tcx> {
14571413 Categorization :: StaticItem => {
14581414 "static item" . into ( )
14591415 }
1460- Categorization :: ThreadLocal ( .. ) => {
1416+ Categorization :: ThreadLocal => {
14611417 "thread-local static item" . into ( )
14621418 }
1463- Categorization :: Rvalue ( .. ) => {
1419+ Categorization :: Rvalue => {
14641420 "non-place" . into ( )
14651421 }
14661422 Categorization :: Local ( vid) => {
0 commit comments