@@ -1319,7 +1319,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1319
1319
| PathSource :: Struct
1320
1320
| PathSource :: TupleStruct ( ..) => false ,
1321
1321
} ;
1322
- let mut error = false ;
1322
+ let mut res = LifetimeRes :: Error ;
1323
1323
for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
1324
1324
match rib. kind {
1325
1325
// In create-parameter mode we error here because we don't want to support
@@ -1329,7 +1329,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1329
1329
// impl Foo for std::cell::Ref<u32> // note lack of '_
1330
1330
// async fn foo(_: std::cell::Ref<u32>) { ... }
1331
1331
LifetimeRibKind :: AnonymousCreateParameter ( _) => {
1332
- error = true ;
1333
1332
break ;
1334
1333
}
1335
1334
// `PassThrough` is the normal case.
@@ -1338,19 +1337,21 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1338
1337
// `PathSegment`, for which there is no associated `'_` or `&T` with no explicit
1339
1338
// lifetime. Instead, we simply create an implicit lifetime, which will be checked
1340
1339
// later, at which point a suitable error will be emitted.
1341
- LifetimeRibKind :: AnonymousPassThrough ( ..)
1342
- | LifetimeRibKind :: AnonymousReportError
1343
- | LifetimeRibKind :: Item => break ,
1340
+ LifetimeRibKind :: AnonymousPassThrough ( binder) => {
1341
+ res = LifetimeRes :: Anonymous { binder, elided : true } ;
1342
+ break ;
1343
+ }
1344
+ LifetimeRibKind :: AnonymousReportError | LifetimeRibKind :: Item => {
1345
+ // FIXME(cjgillot) This resolution is wrong, but this does not matter
1346
+ // since these cases are erroneous anyway. Lifetime resolution should
1347
+ // emit a "missing lifetime specifier" diagnostic.
1348
+ res = LifetimeRes :: Anonymous { binder : DUMMY_NODE_ID , elided : true } ;
1349
+ break ;
1350
+ }
1344
1351
_ => { }
1345
1352
}
1346
1353
}
1347
1354
1348
- let res = if error {
1349
- LifetimeRes :: Error
1350
- } else {
1351
- LifetimeRes :: Anonymous { binder : segment_id, elided : true }
1352
- } ;
1353
-
1354
1355
let node_ids = self . r . next_node_ids ( expected_lifetimes) ;
1355
1356
self . record_lifetime_res (
1356
1357
segment_id,
@@ -1374,7 +1375,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1374
1375
// originating from macros, since the segment's span might be from a macro arg.
1375
1376
segment. ident . span . find_ancestor_inside ( path_span) . unwrap_or ( path_span)
1376
1377
} ;
1377
- if error {
1378
+ if let LifetimeRes :: Error = res {
1378
1379
let sess = self . r . session ;
1379
1380
let mut err = rustc_errors:: struct_span_err!(
1380
1381
sess,
0 commit comments