Skip to content

[NLL] borrowed-universal-test.rs output is not great #48645

Open
@spastorino

Description

@spastorino

The output of this test ...

// compile-flags: -Znll-dump-cause

#![feature(nll)]
#![allow(warnings)]

fn gimme(x: &(u32,)) -> &u32 {
    &x.0
}

fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
    let v = 22;
    gimme(&(v,))
    //~^ ERROR borrowed value does not live long enough [E0597]
}

fn main() {}

is not great

[santiago@archlinux rust1 (borrowed_value_error)]$ rustc +stage1 src/test/ui/nll/borrowed-universal-error.rs -Znll-dump-cause
error[E0597]: borrowed value does not live long enough
  --> src/test/ui/nll/borrowed-universal-error.rs:22:12
   |
22 |     gimme(&(v,))
   |            ^^^^ temporary value does not live long enough
23 |     //~^ ERROR borrowed value does not live long enough [E0597]
24 | }
   | - temporary value only lives until here
   |
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:1...
  --> src/test/ui/nll/borrowed-universal-error.rs:20:1
   |
20 | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

If you want more information on this error, try using "rustc --explain E0597"

cc @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions