Skip to content

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

Closed

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`

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-closuresArea: Closures (`|…| { … }`)
    C-bugCategory: This is a bug.
    on Feb 1, 2019
  2. self-assigned this
    on Feb 5, 2019
  3. added a commit that references this issue on Feb 12, 2019
    16ca0b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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