@@ -65,9 +65,6 @@ struct GuaranteeLifetimeContext<'a> {
6565}
6666
6767impl < ' a > GuaranteeLifetimeContext < ' a > {
68- fn tcx ( & self ) -> & ' a ty:: ctxt {
69- self . bccx . tcx
70- }
7168
7269 fn check ( & self , cmt : & mc:: cmt , discr_scope : Option < ast:: NodeId > ) -> R {
7370 //! Main routine. Walks down `cmt` until we find the "guarantor".
@@ -90,29 +87,10 @@ impl<'a> GuaranteeLifetimeContext<'a> {
9087 Ok ( ( ) )
9188 }
9289
93- mc:: cat_deref( ref base, derefs, mc:: GcPtr ) => {
94- let base_scope = self . scope ( base) ;
95-
96- // L-Deref-Managed-Imm-User-Root
97- let omit_root =
98- self . bccx . is_subregion_of ( self . loan_region , base_scope) &&
99- self . is_rvalue_or_immutable ( base) &&
100- !self . is_moved ( base) ;
101-
102- if !omit_root {
103- // L-Deref-Managed-Imm-Compiler-Root
104- // L-Deref-Managed-Mut-Compiler-Root
105- self . check_root ( cmt, base, derefs, discr_scope)
106- } else {
107- debug ! ( "omitting root, base={}, base_scope={:?}" ,
108- base. repr( self . tcx( ) ) , base_scope) ;
109- Ok ( ( ) )
110- }
111- }
112-
11390 mc:: cat_downcast( ref base) |
11491 mc:: cat_deref( ref base, _, mc:: OwnedPtr ) | // L-Deref-Send
115- mc:: cat_interior( ref base, _) => { // L-Field
92+ mc:: cat_interior( ref base, _) | // L-Field
93+ mc:: cat_deref( ref base, _, mc:: GcPtr ) => {
11694 self . check ( base, discr_scope)
11795 }
11896
@@ -174,74 +152,6 @@ impl<'a> GuaranteeLifetimeContext<'a> {
174152 }
175153 }
176154
177- fn is_rvalue_or_immutable ( & self ,
178- cmt : & mc:: cmt ) -> bool {
179- //! We can omit the root on an `@T` value if the location
180- //! that holds the box is either (1) an rvalue, in which case
181- //! it is in a non-user-accessible temporary, or (2) an immutable
182- //! lvalue.
183-
184- cmt. mutbl . is_immutable ( ) || match cmt. guarantor ( ) . cat {
185- mc:: cat_rvalue( ..) => true ,
186- _ => false
187- }
188- }
189-
190- fn check_root ( & self ,
191- cmt_deref : & mc:: cmt ,
192- cmt_base : & mc:: cmt ,
193- derefs : uint ,
194- discr_scope : Option < ast:: NodeId > ) -> R {
195- debug ! ( "check_root(cmt_deref={}, cmt_base={}, derefs={:?}, \
196- discr_scope={:?})",
197- cmt_deref. repr( self . tcx( ) ) ,
198- cmt_base. repr( self . tcx( ) ) ,
199- derefs,
200- discr_scope) ;
201-
202- // Make sure that the loan does not exceed the maximum time
203- // that we can root the value, dynamically.
204- let root_region = ty:: ReScope ( self . root_scope_id ) ;
205- if !self . bccx . is_subregion_of ( self . loan_region , root_region) {
206- return Err ( self . report_error (
207- err_out_of_root_scope ( root_region, self . loan_region ) ) ) ;
208- }
209-
210- // Extract the scope id that indicates how long the rooting is required
211- let root_scope = match self . loan_region {
212- ty:: ReScope ( id) => id,
213- _ => {
214- // the check above should fail for anything is not ReScope
215- self . bccx . tcx . sess . span_bug (
216- cmt_base. span ,
217- format ! ( "cannot issue root for scope region: {:?}" ,
218- self . loan_region) ) ;
219- }
220- } ;
221-
222- // If inside of a match arm, expand the rooting to the entire
223- // match. See the detailed discussion in `check()` above.
224- let root_scope = match discr_scope {
225- None => root_scope,
226- Some ( id) => {
227- if self . bccx . is_subscope_of ( root_scope, id) {
228- id
229- } else {
230- root_scope
231- }
232- }
233- } ;
234-
235- // Add a record of what is required
236- let rm_key = root_map_key { id : cmt_deref. id , derefs : derefs} ;
237- let root_info = RootInfo { scope : root_scope} ;
238-
239- self . bccx . root_map . borrow_mut ( ) . insert ( rm_key, root_info) ;
240-
241- debug ! ( "root_key: {:?} root_info: {:?}" , rm_key, root_info) ;
242- Ok ( ( ) )
243- }
244-
245155 fn check_scope ( & self , max_scope : ty:: Region ) -> R {
246156 //! Reports an error if `loan_region` is larger than `valid_scope`
247157
@@ -252,32 +162,6 @@ impl<'a> GuaranteeLifetimeContext<'a> {
252162 }
253163 }
254164
255- fn is_moved ( & self , cmt : & mc:: cmt ) -> bool {
256- //! True if `cmt` is something that is potentially moved
257- //! out of the current stack frame.
258-
259- match cmt. guarantor ( ) . cat {
260- mc:: cat_local( id) |
261- mc:: cat_arg( id) => {
262- self . bccx . moved_variables_set . contains ( & id)
263- }
264- mc:: cat_rvalue( ..) |
265- mc:: cat_static_item |
266- mc:: cat_copied_upvar( ..) |
267- mc:: cat_deref( ..) |
268- mc:: cat_upvar( ..) => {
269- false
270- }
271- ref r @ mc:: cat_downcast( ..) |
272- ref r @ mc:: cat_interior( ..) |
273- ref r @ mc:: cat_discr( ..) => {
274- self . tcx ( ) . sess . span_bug (
275- cmt. span ,
276- format ! ( "illegal guarantor category: {:?}" , r) ) ;
277- }
278- }
279- }
280-
281165 fn scope ( & self , cmt : & mc:: cmt ) -> ty:: Region {
282166 //! Returns the maximal region scope for the which the
283167 //! lvalue `cmt` is guaranteed to be valid without any
0 commit comments