@@ -59,10 +59,10 @@ struct LifetimeContext<'a> {
59
59
enum ScopeChain < ' a > {
60
60
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
61
61
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
62
- EarlyScope ( subst:: ParamSpace , & ' a Vec < ast:: Lifetime > , Scope < ' a > ) ,
62
+ EarlyScope ( subst:: ParamSpace , & ' a Vec < ast:: LifetimeDef > , Scope < ' a > ) ,
63
63
/// LateScope(binder_id, ['a, 'b, ...], s) extends s with late-bound
64
64
/// lifetimes introduced by the declaration binder_id.
65
- LateScope ( ast:: NodeId , & ' a Vec < ast:: Lifetime > , Scope < ' a > ) ,
65
+ LateScope ( ast:: NodeId , & ' a Vec < ast:: LifetimeDef > , Scope < ' a > ) ,
66
66
/// lifetimes introduced by items within a code block are scoped
67
67
/// to that block.
68
68
BlockScope ( ast:: NodeId , Scope < ' a > ) ,
@@ -136,7 +136,7 @@ impl<'a, 'b> Visitor<Scope<'a>> for LifetimeContext<'b> {
136
136
fn push_fn_scope ( this : & mut LifetimeContext ,
137
137
ty : & ast:: Ty ,
138
138
scope : Scope ,
139
- lifetimes : & Vec < ast:: Lifetime > ) {
139
+ lifetimes : & Vec < ast:: LifetimeDef > ) {
140
140
let scope1 = LateScope ( ty. id , lifetimes, scope) ;
141
141
this. check_lifetime_names ( lifetimes) ;
142
142
debug ! ( "pushing fn scope id={} due to type" , ty. id) ;
@@ -216,7 +216,7 @@ impl<'a> LifetimeContext<'a> {
216
216
walk ( self , & scope1)
217
217
} else {
218
218
let ( early, late) = generics. lifetimes . clone ( ) . partition (
219
- |l| referenced_idents. iter ( ) . any ( |& i| i == l. name ) ) ;
219
+ |l| referenced_idents. iter ( ) . any ( |& i| i == l. lifetime . name ) ) ;
220
220
221
221
let scope1 = EarlyScope ( subst:: FnSpace , & early, scope) ;
222
222
let scope2 = LateScope ( n, & late, & scope1) ;
@@ -334,29 +334,39 @@ impl<'a> LifetimeContext<'a> {
334
334
token:: get_name( lifetime_ref. name) ) . as_slice ( ) ) ;
335
335
}
336
336
337
- fn check_lifetime_names ( & self , lifetimes : & Vec < ast:: Lifetime > ) {
337
+ fn check_lifetime_names ( & self , lifetimes : & Vec < ast:: LifetimeDef > ) {
338
338
for i in range ( 0 , lifetimes. len ( ) ) {
339
339
let lifetime_i = lifetimes. get ( i) ;
340
340
341
341
let special_idents = [ special_idents:: static_lifetime] ;
342
342
for lifetime in lifetimes. iter ( ) {
343
- if special_idents. iter ( ) . any ( |& i| i. name == lifetime. name ) {
343
+ if special_idents. iter ( ) . any ( |& i| i. name == lifetime. lifetime . name ) {
344
344
self . sess . span_err (
345
- lifetime. span ,
345
+ lifetime. lifetime . span ,
346
346
format ! ( "illegal lifetime parameter name: `{}`" ,
347
- token:: get_name( lifetime. name) ) . as_slice ( ) ) ;
347
+ token:: get_name( lifetime. lifetime. name) )
348
+ . as_slice ( ) ) ;
348
349
}
349
350
}
350
351
351
352
for j in range ( i + 1 , lifetimes. len ( ) ) {
352
353
let lifetime_j = lifetimes. get ( j) ;
353
354
354
- if lifetime_i. name == lifetime_j. name {
355
+ if lifetime_i. lifetime . name == lifetime_j. lifetime . name {
355
356
self . sess . span_err (
356
- lifetime_j. span ,
357
+ lifetime_j. lifetime . span ,
357
358
format ! ( "lifetime name `{}` declared twice in \
358
359
the same scope",
359
- token:: get_name( lifetime_j. name) ) . as_slice ( ) ) ;
360
+ token:: get_name( lifetime_j. lifetime. name) )
361
+ . as_slice ( ) ) ;
362
+ }
363
+ }
364
+
365
+ for bound in lifetime_i. bounds . iter ( ) {
366
+ if !self . sess . features . issue_5723_bootstrap . get ( ) {
367
+ self . sess . span_err (
368
+ bound. span ,
369
+ "region bounds require `issue_5723_bootstrap`" ) ;
360
370
}
361
371
}
362
372
}
@@ -379,28 +389,28 @@ impl<'a> LifetimeContext<'a> {
379
389
}
380
390
}
381
391
382
- fn search_lifetimes ( lifetimes : & Vec < ast:: Lifetime > ,
392
+ fn search_lifetimes ( lifetimes : & Vec < ast:: LifetimeDef > ,
383
393
lifetime_ref : & ast:: Lifetime )
384
394
-> Option < ( uint , ast:: NodeId ) > {
385
395
for ( i, lifetime_decl) in lifetimes. iter ( ) . enumerate ( ) {
386
- if lifetime_decl. name == lifetime_ref. name {
387
- return Some ( ( i, lifetime_decl. id ) ) ;
396
+ if lifetime_decl. lifetime . name == lifetime_ref. name {
397
+ return Some ( ( i, lifetime_decl. lifetime . id ) ) ;
388
398
}
389
399
}
390
400
return None ;
391
401
}
392
402
393
403
///////////////////////////////////////////////////////////////////////////
394
404
395
- pub fn early_bound_lifetimes < ' a > ( generics : & ' a ast:: Generics ) -> Vec < ast:: Lifetime > {
405
+ pub fn early_bound_lifetimes < ' a > ( generics : & ' a ast:: Generics ) -> Vec < ast:: LifetimeDef > {
396
406
let referenced_idents = free_lifetimes ( & generics. ty_params ) ;
397
407
if referenced_idents. is_empty ( ) {
398
408
return Vec :: new ( ) ;
399
409
}
400
410
401
411
generics. lifetimes . iter ( )
402
- . filter ( |l| referenced_idents. iter ( ) . any ( |& i| i == l. name ) )
403
- . map ( |l| * l )
412
+ . filter ( |l| referenced_idents. iter ( ) . any ( |& i| i == l. lifetime . name ) )
413
+ . map ( |l| ( * l ) . clone ( ) )
404
414
. collect ( )
405
415
}
406
416
0 commit comments