Skip to content

"use of undeclared lifetime name 'static" is misleading #40661

Closed

Description

Code: https://is.gd/6L8tEl

fn foo<'a: 'static>() {}

Output:

rustc 1.17.0-nightly (b1e31766d 2017-03-03)
error[E0261]: use of undeclared lifetime name `'static`
 --> <anon>:1:12
  |
1 | fn foo<'a: 'static>() {}
  |            ^^^^^^^ undeclared lifetime

Expectation:

<'a: 'static> is unnecessary (you can just use 'static in place of 'a), but maybe we should accept it? At any rate, the error message is misleading - 'static is the one globally declared lifetime. If we want to reject this code, the error message should not imply 'static is undefined, but rather that you just don't need the 'a lifetime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name resolutionArea: Name resolutionE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions