Skip to content

Better error message for enforcing that lifetime parameters precede type parameters in declaration lists #14303

Closed
@bstrie

Description

@bstrie

Consider the following program:

fn main() {}
fn foo<T, 'a>(x: &'a T) {}

Compiling gives this error:

lf.rs:2:11: 2:13 error: expected ident, found `'a`
lf.rs:2 fn foo<T, 'a>(x: &'a T) {}
                  ^~

This error message obscures the fact that, for consistency's sake, we require lifetime parameters to precede type parameters in the type parameter declaration list.

I propose the following error message:

lf.rs:2:11: 2:13 error: lifetime parameters must be declared prior to type parameters
lf.rs:2 fn foo<T, 'a>(x: &'a T) {}
                  ^~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions