Skip to content

NLL: closure return-type highlighting does not handle annotation right #58053

Closed
@pnkfelix

Description

@pnkfelix

Code (play):

#![feature(nll)]

fn main() {
    let f = |x: &i32| -> &i32 { x };
    let i = &3;
    let j = f(i);
}

yields:

error: lifetime may not live long enough
 --> src/main.rs:4:33
  |
4 |     let f = |x: &i32| -> &i32 { x };
  |                 -           -   ^ returning this value requires that `'1` must outlive `'2`
  |                 |           |
  |                 |           return type of closure is &'2 i32
  |                 let's call the lifetime of this reference `'1`

but I would have expected it to use the span:

error: lifetime may not live long enough
 --> src/main.rs:4:33
  |
4 |     let f = |x: &i32| -> &i32 { x };
  |                 -        -      ^ returning this value requires that `'1` must outlive `'2`
  |                 |        |
  |                 |        return type of closure is &'2 i32
  |                 let's call the lifetime of this reference `'1`

Metadata

Metadata

Assignees

Labels

A-closuresArea: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions