Skip to content

Add a builtin_type_shadow lint #1199

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

Merged
merged 1 commit into from
Aug 28, 2016
Merged

Add a builtin_type_shadow lint #1199

merged 1 commit into from
Aug 28, 2016

Conversation

mcarton
Copy link
Member

@mcarton mcarton commented Aug 27, 2016

@@ -141,6 +141,27 @@ declare_lint! {
"integer literals starting with `0`"
}

/// **What it does:** Warns if a generic shadows a built-in type.
///
/// **Why is this bad?** This gives surprising type error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either 'errors' or 'a surprising type error'

@mcarton
Copy link
Member Author

mcarton commented Aug 28, 2016

Rebased and addressed comments.

@killercup
Copy link
Member

LGTM

I was confused by the wording ("shadowing") a bit, bit it makes sense. (Maybe we can add a span label for the generic name later on, saying something like "The generic {} has the same name as a built-in type", just to also have alternative wording.)

@llogiq llogiq merged commit c54457c into master Aug 28, 2016
@llogiq llogiq deleted the shadow-builtin branch August 28, 2016 18:37
@llogiq
Copy link
Contributor

llogiq commented Aug 28, 2016

Good lint. @Manishearth we should propose adding this to rustc. It's really a footgun.

@Manishearth
Copy link
Member

Not as a lint, but that error message could get a help message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants