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

[1.38] Regression: missing unused import warning #81368

Closed
dylni opened this issue Jan 25, 2021 · 4 comments
Closed

[1.38] Regression: missing unused import warning #81368

dylni opened this issue Jan 25, 2021 · 4 comments
Labels
regression-untriaged Untriaged performance or correctness regression.

Comments

@dylni
Copy link
Contributor

dylni commented Jan 25, 2021

Code

I tried this code:

use std::clone::Clone;

#[derive(Clone)]
struct S;

fn main() {}

I expected to see this happen: The code compiles with a warning about the import being unused.

Instead, this happened: The code compiles with no warnings.

Version it worked on

It most recently worked on: Rust 1.37

Version with regression

rustc --version --verbose:

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
@dylni
Copy link
Contributor Author

dylni commented Jan 25, 2021

@rustbot modify labels: +regression-untriaged

@rustbot rustbot added regression-untriaged Untriaged performance or correctness regression. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 25, 2021
@dylni
Copy link
Contributor Author

dylni commented Jan 25, 2021

This is old, so I-prioritize is likely not relevant. Will this work?

@rustbot modify labels: -I-prioritize

@rustbot rustbot removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 25, 2021
@ehuss
Copy link
Contributor

ehuss commented Jan 25, 2021

I believe this is working as intended. use std::clone::Clone; imports both the trait and the derive macro (which lives in different namespaces). Thus the #[derive(Clone)] is using the derive that you imported, not the one in the standard library prelude (it is shadowed by the import). They are one in the same, but you could also write use my_derive_macro::Clone; and it would use a different derive. I believe this started with #63056.

@dylni
Copy link
Contributor Author

dylni commented Jan 26, 2021

@ehuss Thanks for the explanation. I didn't consider that the prelude Clone is a re-export, so they're not the same. The prelude could be considered special for detecting unused imports, but I don't think that's necessary.

@dylni dylni closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-untriaged Untriaged performance or correctness regression.
Projects
None yet
Development

No branches or pull requests

3 participants