Skip to content

misleading E0392 "parameter T is never used" for every containing struct #66912

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

Open
geogriff-signal opened this issue Nov 30, 2019 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@geogriff-signal
Copy link

Rustc emits an error for every struct containing a struct with an unused type parameter. Unless there's some edge case I'm not thinking of, this seems pointless, as the user will eventually have to fix the "leaf" struct (that which is the root of the problem), which would then fix the entire tree of structs.

I tried this code:

struct Foo<T> {
    bar: Bar<T>,
}
struct Bar<T> {}

I expected to see this happen:

error[E0392]: parameter `T` is never used
 --> src/main.rs:4:12
  |
5 | struct Bar<T> {}
  |            ^ unused parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to previous error

Instead, this happened:

error[E0392]: parameter `T` is never used
 --> src/main.rs:1:12
  |
1 | struct Foo<T> {
  |            ^ unused parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `T` is never used
 --> src/main.rs:4:12
  |
4 | struct Bar<T> {}
  |            ^ unused parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Meta

rustc --version --verbose:
rustc 1.41.0-nightly (25d8a94 2019-11-29)
binary: rustc
commit-hash: 25d8a94
commit-date: 2019-11-29
host: x86_64-unknown-linux-gnu
release: 1.41.0-nightly
LLVM version: 9.0

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 30, 2019
@steveklabnik
Copy link
Member

Triage: trying this today, the same error happens.

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 C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants