@@ -223,13 +223,6 @@ pub struct RegionMaps {
223223 /// block (see `terminating_scopes`).
224224 rvalue_scopes : NodeMap < CodeExtent > ,
225225
226- /// Records the value of rvalue scopes before they were shrunk by
227- /// #36082, for error reporting.
228- ///
229- /// FIXME: this should be temporary. Remove this by 1.18.0 or
230- /// so.
231- shrunk_rvalue_scopes : NodeMap < CodeExtent > ,
232-
233226 /// Encodes the hierarchy of fn bodies. Every fn body (including
234227 /// closures) forms its own distinct region hierarchy, rooted in
235228 /// the block that is the fn body. This map points from the id of
@@ -301,7 +294,6 @@ impl<'tcx> RegionMaps {
301294 destruction_scopes : FxHashMap ( ) ,
302295 var_map : NodeMap ( ) ,
303296 rvalue_scopes : NodeMap ( ) ,
304- shrunk_rvalue_scopes : NodeMap ( ) ,
305297 fn_tree : NodeMap ( ) ,
306298 }
307299 }
@@ -370,12 +362,6 @@ impl<'tcx> RegionMaps {
370362 self . rvalue_scopes . insert ( var, lifetime) ;
371363 }
372364
373- fn record_shrunk_rvalue_scope ( & mut self , var : ast:: NodeId , lifetime : CodeExtent ) {
374- debug ! ( "record_rvalue_scope(sub={:?}, sup={:?})" , var, lifetime) ;
375- assert ! ( var != lifetime. node_id( ) ) ;
376- self . shrunk_rvalue_scopes . insert ( var, lifetime) ;
377- }
378-
379365 pub fn opt_encl_scope ( & self , id : CodeExtent ) -> Option < CodeExtent > {
380366 //! Returns the narrowest scope that encloses `id`, if any.
381367 self . scope_map . get ( & id) . cloned ( )
@@ -395,32 +381,6 @@ impl<'tcx> RegionMaps {
395381 }
396382 }
397383
398- pub fn temporary_scope2 ( & self , expr_id : ast:: NodeId )
399- -> ( Option < CodeExtent > , bool ) {
400- let temporary_scope = self . temporary_scope ( expr_id) ;
401- let was_shrunk = match self . shrunk_rvalue_scopes . get ( & expr_id) {
402- Some ( & s) => {
403- info ! ( "temporary_scope2({:?}, scope={:?}, shrunk={:?})" ,
404- expr_id, temporary_scope, s) ;
405- temporary_scope != Some ( s)
406- }
407- _ => false
408- } ;
409- info ! ( "temporary_scope2({:?}) - was_shrunk={:?}" , expr_id, was_shrunk) ;
410- ( temporary_scope, was_shrunk)
411- }
412-
413- pub fn old_and_new_temporary_scope ( & self , expr_id : ast:: NodeId )
414- -> ( Option < CodeExtent > ,
415- Option < CodeExtent > )
416- {
417- let temporary_scope = self . temporary_scope ( expr_id) ;
418- ( temporary_scope,
419- self . shrunk_rvalue_scopes
420- . get ( & expr_id) . cloned ( )
421- . or ( temporary_scope) )
422- }
423-
424384 pub fn temporary_scope ( & self , expr_id : ast:: NodeId ) -> Option < CodeExtent > {
425385 //! Returns the scope when temp created by expr_id will be cleaned up
426386
@@ -896,10 +856,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
896856 // Rule A. `let (ref x, ref y) = (foo().x, 44)`. The rvalue `(22, 44)`
897857 // would have an extended lifetime, but not `foo()`.
898858 //
899- // Rule B. `let x: &[...] = [foo().x]`. The rvalue `[foo().x]`
900- // would have an extended lifetime, but not `foo()`.
901- //
902- // Rule C. `let x = &foo().x`. The rvalue ``foo()` would have extended
859+ // Rule B. `let x = &foo().x`. The rvalue ``foo()` would have extended
903860 // lifetime.
904861 //
905862 // In some cases, multiple rules may apply (though not to the same
@@ -916,13 +873,8 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
916873 if let Some ( ref expr) = local. init {
917874 record_rvalue_scope_if_borrow_expr ( visitor, & expr, blk_scope) ;
918875
919- let is_borrow =
920- if let Some ( ref ty) = local. ty { is_borrowed_ty ( & ty) } else { false } ;
921-
922876 if is_binding_pat ( & local. pat ) {
923- record_rvalue_scope ( visitor, & expr, blk_scope, false ) ;
924- } else if is_borrow {
925- record_rvalue_scope ( visitor, & expr, blk_scope, true ) ;
877+ record_rvalue_scope ( visitor, & expr, blk_scope) ;
926878 }
927879 }
928880
@@ -963,14 +915,6 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
963915 }
964916 }
965917
966- /// True if `ty` is a borrowed pointer type like `&int` or `&[...]`.
967- fn is_borrowed_ty ( ty : & hir:: Ty ) -> bool {
968- match ty. node {
969- hir:: TyRptr ( ..) => true ,
970- _ => false
971- }
972- }
973-
974918 /// If `expr` matches the `E&` grammar, then records an extended rvalue scope as appropriate:
975919 ///
976920 /// E& = & ET
@@ -989,7 +933,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
989933 match expr. node {
990934 hir:: ExprAddrOf ( _, ref subexpr) => {
991935 record_rvalue_scope_if_borrow_expr ( visitor, & subexpr, blk_id) ;
992- record_rvalue_scope ( visitor, & subexpr, blk_id, false ) ;
936+ record_rvalue_scope ( visitor, & subexpr, blk_id) ;
993937 }
994938 hir:: ExprStruct ( _, ref fields, _) => {
995939 for field in fields {
@@ -1034,21 +978,15 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
1034978 /// Note: ET is intended to match "rvalues or lvalues based on rvalues".
1035979 fn record_rvalue_scope < ' a , ' tcx > ( visitor : & mut RegionResolutionVisitor < ' a , ' tcx > ,
1036980 expr : & hir:: Expr ,
1037- blk_scope : CodeExtent ,
1038- is_shrunk : bool ) {
981+ blk_scope : CodeExtent ) {
1039982 let mut expr = expr;
1040983 loop {
1041984 // Note: give all the expressions matching `ET` with the
1042985 // extended temporary lifetime, not just the innermost rvalue,
1043986 // because in trans if we must compile e.g. `*rvalue()`
1044987 // into a temporary, we request the temporary scope of the
1045988 // outer expression.
1046- if is_shrunk {
1047- // this changed because of #36082
1048- visitor. region_maps . record_shrunk_rvalue_scope ( expr. id , blk_scope) ;
1049- } else {
1050- visitor. region_maps . record_rvalue_scope ( expr. id , blk_scope) ;
1051- }
989+ visitor. region_maps . record_rvalue_scope ( expr. id , blk_scope) ;
1052990
1053991 match expr. node {
1054992 hir:: ExprAddrOf ( _, ref subexpr) |
0 commit comments