Skip to content

Lifetimes are inconsistently printed with backticks #65287

Closed
@varkor

Description

@varkor
fn foo<'a>(u: &'a usize) -> impl IntoIterator<Item = usize> + 'a {
    std::thread::spawn(|| {
        println!("{}", u);
    });
    vec![]
}

displays:

error: cannot infer an appropriate lifetime
 --> src/lib.rs:2:24
  |
2 |       std::thread::spawn(|| {
  |  _____------------------_^
  | |     |
  | |     this return type evaluates to the `'static` lifetime...
3 | |         println!("{}", u);
4 | |     });
  | |_____^ ...but this borrow...
  |
note: ...can't outlive the lifetime 'a as defined on the function body at 1:8

Notice how `'static` is surrounded in backticks, but 'a is not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-inconsistentDiagnostics: Inconsistency in formatting, grammar or style between diagnostic messages.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-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