-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Warn on shadowing generics #11658
Comments
Example of the errors: struct Foo<T>(T);
impl<T> Foo<T> {
fn new<T>(x: T) -> Foo<T> { Foo(x) }
}
fn main() {
Foo::new(1i);
}
It's the (This cannot be just a lint, since typechecking failures kill compilation well before lints run.) |
A solution for this would probably also fix #9914. |
DST seems to have made the error messages for this a lot less clearer than they have already been. |
We do in fact warn for this now. From @huonw 's example:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given the following:
I would suggest that shadowing the generics in the new function should cause a warning. I'm still getting my mind wrapped around rust and the error message that I got in the previous case was pretty cryptic. Once I saw what was happening, it was obvious. I think a warning would have helped a lot.
The text was updated successfully, but these errors were encountered: