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 when known types are used as generic placeholders #54905

lu-zero opened this Issue Oct 8, 2018 · 3 comments


None yet
2 participants

lu-zero commented Oct 8, 2018

Since hardly it is what you want and it leads to funny error messages, here an example:

struct S<T> {
    foo: T,
impl<u16> S<u16> {
    fn fee(&self, idx: usize) -> u16 {
        if ( as usize) < idx {
            idx as u16
        } else {
fn main() {
    let f: S<u16> = S { foo: 42 };
    println!(" {}", f.fee(13));

This comment has been minimized.


oli-obk commented Oct 8, 2018

Clippy reports

warning: This generic shadows the built-in type `u16`
 --> src/
4 | impl<u16> S<u16> {
  |      ^^^
  = note: #[warn(clippy::builtin_type_shadow)] on by default
  = help: for further information visit

Adding new warnings to rustc requires an RFC, as such I am going to close this. If the existing clippy lint is not covering your use cases, please don't hesitate to open an issue on the clippy repository

@oli-obk oli-obk closed this Oct 8, 2018


This comment has been minimized.


lu-zero commented Oct 13, 2018

I'd rather have this in rustc since the current error is quite confusing, do you have an example rfc I can use as template?


This comment has been minimized.


oli-obk commented Oct 13, 2018

Unfortunately not, I don't know of any RFC that just added a lint.

@lu-zero lu-zero referenced this issue Oct 23, 2018


Uplift lints from clippy to rustc #53224

32 of 49 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment