Skip to content
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

Compiler allows type aliases with unused lifetime parameters #35160

Closed
abonander opened this issue Aug 1, 2016 · 7 comments
Closed

Compiler allows type aliases with unused lifetime parameters #35160

abonander opened this issue Aug 1, 2016 · 7 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@abonander
Copy link
Contributor

abonander commented Aug 1, 2016

First noticed with this funky type alias, which probably needed a lifetime at one point but doesn't anymore.

Simplest case is the most trivial: create a type alias with a lifetime parameter, but don't use it on the RHS:

// No Error
pub type MyType<'a> = String;

// Errors
// pub type MyType<T> = String;

// Errors
// pub struct MyType<'a> {}

Playground

The linked example compiles on all three channels.

As far as I understand it, unused type parameters are always supposed to be hard errors, as established in RFC 738, so this must be a corner case that was never implemented, or otherwise a regression. I haven't tested previous releases, I might do that tomorrow if someone hasn't gotten to this already,

@eddyb
Copy link
Member

eddyb commented Aug 1, 2016

You can't misuse it because the checks are done on the semantic type, so it sees right through type aliases, e.g. impl<'a> Foo for MyType<'a> will fail because Foo for String doesn't mention 'a.

@abonander
Copy link
Contributor Author

@eddyb
Copy link
Member

eddyb commented Aug 2, 2016

@cybergeek94 You're not using it anywhere so it's actually ignored, apparently. Here's the error.

@Mark-Simulacrum
Copy link
Member

I'm going to mark this is a diagnostics issue since it's likely an error centering on the type alias's definition site would be a lot more helpful here.

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label May 10, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of #35160.

@abonander
Copy link
Contributor Author

@Mark-Simulacrum you just closed this issue in favor of itself.

@Mark-Simulacrum
Copy link
Member

Someone fix clipboards please; #41960.

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

No branches or pull requests

3 participants