@@ -1422,7 +1422,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1422
1422
let lifetime_i = & lifetimes[ i] ;
1423
1423
1424
1424
for lifetime in lifetimes {
1425
- if lifetime. lifetime . is_static ( ) {
1425
+ if lifetime. lifetime . is_static ( ) || lifetime . lifetime . name == "'_" {
1426
1426
let lifetime = lifetime. lifetime ;
1427
1427
let mut err = struct_span_err ! ( self . sess, lifetime. span, E0262 ,
1428
1428
"invalid lifetime parameter name: `{}`" , lifetime. name) ;
@@ -1452,7 +1452,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1452
1452
self . check_lifetime_def_for_shadowing ( old_scope, & lifetime_i. lifetime ) ;
1453
1453
1454
1454
for bound in & lifetime_i. bounds {
1455
- if !bound. is_static ( ) {
1455
+ if bound. name == "'_" {
1456
+ let mut err = struct_span_err ! ( self . sess, bound. span, E0637 ,
1457
+ "invalid lifetime bound name: `{}`" , bound. name) ;
1458
+ err. span_label ( bound. span ,
1459
+ format ! ( "{} is a reserved lifetime name" , bound. name) ) ;
1460
+ err. emit ( ) ;
1461
+ } else if !bound. is_static ( ) {
1456
1462
self . resolve_lifetime_ref ( bound) ;
1457
1463
} else {
1458
1464
self . insert_lifetime ( bound, Region :: Static ) ;
0 commit comments