Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bstrie opened this issue May 20, 2014 · 0 comments · Fixed by #14389
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@bstrie
Copy link
Contributor

bstrie commented May 20, 2014

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) {}
                  ^~
Ryman added a commit to Ryman/rust that referenced this issue May 24, 2014
bors added a commit that referenced this issue May 24, 2014
flip1995 added a commit to flip1995/rust that referenced this issue Feb 27, 2025
It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the `check_item` will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()` call can
be completely removed.

Fixes rust-lang#14303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant