You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a unused import (either specific or glob) is followed by a glob import that shadows it (and thus causes the first to go unused), the unused import lint is incorrectly blaming/identifying the latter glob as being unused, and failing to identify the former import as being unused.
Nearly exhaustive and certainly exhausting test case (multuse.rs):
modA{pubfnp(){println("A::p");}}modB{pubfnp(){println("B::p");}}modC{pubfnq(){println("C::q");}}modD{pubfnq(){println("D::q");}}modE{pubfnr(){println("E::r");}}modF{pubfnr(){println("E::r");}}modG{pubfns(){println("G::s");}pubfnt(){println("G::t");}}modH{pubfns(){println("H::s");}}modI{pubfnu(){println("I::u");}pubfnv(){println("I::v");}}modJ{pubfnu(){println("J::u");}pubfnv(){println("J::v");}}modK{pubfnw(){println("K::w");}}modL{pubfnw(){println("L::w");}}mod m {useA::p;// <-- this `p` is unused; correctly warnsuseB::p;useC::q;// <-- this `q` is unused, but NO WARNINGuseD::*;// <-- this `q` IS USED, yields false positive warninguseE::*;// <-- this `r` is overridden and unused; correctly warnsuseF::r;useG::*;// <-- this `s` is overridden, no warning since t is used, as expected for glob.useH::*;// <-- this `s` is USED, yields false positive warninguseI::*;// <-- this `v` is overridden, no warning since u is used, as expected for globuseJ::v;useK::*;// <-- all imports here are overriden, none used, but NO WARNINGuseL::*;// <-- this `w` is USED, yields false positive warning#[main]fnmy_main(){p();q();r();s();t();u();v();w();}}
Result of the run (to confirm what the comments next to the uses say):
% rustc /tmp/multuse.rs && /tmp/multuse
/tmp/multuse.rs:47:7: 47:11 warning: unused import [-W unused-imports (default)]
/tmp/multuse.rs:47 use A::p; // <-- this `p` is unused; correctly warns
^~~~
/tmp/multuse.rs:50:7: 50:12 warning: unused import [-W unused-imports (default)]
/tmp/multuse.rs:50 use D::*; // <-- this `q` IS USED, yields false positive warning
^~~~~
/tmp/multuse.rs:51:7: 51:12 warning: unused import [-W unused-imports (default)]
/tmp/multuse.rs:51 use E::*; // <-- this `r` is overridden and unused; correctly warns
^~~~~
/tmp/multuse.rs:54:7: 54:12 warning: unused import [-W unused-imports (default)]
/tmp/multuse.rs:54 use H::*; // <-- this `s` is USED, yields false positive warning
^~~~~
/tmp/multuse.rs:58:7: 58:12 warning: unused import [-W unused-imports (default)]
/tmp/multuse.rs:58 use L::*; // <-- this `w` is USED, yields false positive warning
^~~~~
warning: no debug symbols in executable (-arch x86_64)
B::p
D::q
E::r
H::s
G::t
I::u
J::v
L::w
The text was updated successfully, but these errors were encountered:
add [`as_underscore`] lint
closesrust-lang#8847
detect usage of `as _` and enforce the usage of explicit type like
```rust
fn foo(n: usize) {}
let n: u16 = 256;
foo(n as _);
```
will suggest to change to
```rust
fn foo(n: usize) {}
let n: u16 = 256;
foo(n as usize);
```
changelog: add [`as_underscore`] lint
Spawned off of "fun note" at end of #7663.
When a unused import (either specific or glob) is followed by a glob import that shadows it (and thus causes the first to go unused), the unused import lint is incorrectly blaming/identifying the latter glob as being unused, and failing to identify the former import as being unused.
Nearly exhaustive and certainly exhausting test case (multuse.rs):
Result of the run (to confirm what the comments next to the uses say):
The text was updated successfully, but these errors were encountered: