File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -5089,6 +5089,9 @@ impl<'a> Resolver<'a> {
50895089 }
50905090 self . extern_prelude . get ( & ident. modern ( ) ) . cloned ( ) . and_then ( |entry| {
50915091 if let Some ( binding) = entry. extern_crate_item {
5092+ if !speculative && entry. introduced_by_item {
5093+ self . record_use ( ident, TypeNS , binding, false ) ;
5094+ }
50925095 Some ( binding)
50935096 } else {
50945097 let crate_id = if !speculative {
Original file line number Diff line number Diff line change 1+ // Extern crate items are marked as used if they are used
2+ // through extern prelude entries introduced by them.
3+
4+ // edition:2018
5+
6+ #![ deny( unused_extern_crates) ]
7+
8+ extern crate core as iso1; //~ ERROR `extern crate` is not idiomatic in the new edition
9+ extern crate core as iso2; //~ ERROR `extern crate` is not idiomatic in the new edition
10+ extern crate core as iso3; //~ ERROR `extern crate` is not idiomatic in the new edition
11+ extern crate core as iso4; //~ ERROR `extern crate` is not idiomatic in the new edition
12+
13+ // Doesn't introduce its extern prelude entry, so it's still considered unused.
14+ extern crate core; //~ ERROR unused extern crate
15+
16+ mod m {
17+ use iso1:: any as are_you_okay1;
18+ use :: iso2:: any as are_you_okay2;
19+ type AreYouOkay1 = iso3:: any:: Any ;
20+ type AreYouOkay2 = :: iso4:: any:: Any ;
21+
22+ use core:: any as are_you_okay3;
23+ use :: core:: any as are_you_okay4;
24+ type AreYouOkay3 = core:: any:: Any ;
25+ type AreYouOkay4 = :: core:: any:: Any ;
26+ }
27+
28+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: `extern crate` is not idiomatic in the new edition
2+ --> $DIR/extern-crate-used.rs:8:1
3+ |
4+ LL | extern crate core as iso1; //~ ERROR `extern crate` is not idiomatic in the new edition
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
6+ |
7+ note: lint level defined here
8+ --> $DIR/extern-crate-used.rs:6:9
9+ |
10+ LL | #![deny(unused_extern_crates)]
11+ | ^^^^^^^^^^^^^^^^^^^^
12+
13+ error: `extern crate` is not idiomatic in the new edition
14+ --> $DIR/extern-crate-used.rs:9:1
15+ |
16+ LL | extern crate core as iso2; //~ ERROR `extern crate` is not idiomatic in the new edition
17+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
18+
19+ error: `extern crate` is not idiomatic in the new edition
20+ --> $DIR/extern-crate-used.rs:10:1
21+ |
22+ LL | extern crate core as iso3; //~ ERROR `extern crate` is not idiomatic in the new edition
23+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
24+
25+ error: `extern crate` is not idiomatic in the new edition
26+ --> $DIR/extern-crate-used.rs:11:1
27+ |
28+ LL | extern crate core as iso4; //~ ERROR `extern crate` is not idiomatic in the new edition
29+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
30+
31+ error: unused extern crate
32+ --> $DIR/extern-crate-used.rs:14:1
33+ |
34+ LL | extern crate core; //~ ERROR unused extern crate
35+ | ^^^^^^^^^^^^^^^^^^ help: remove it
36+
37+ error: aborting due to 5 previous errors
38+
You can’t perform that action at this time.
0 commit comments