]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unnecessary-extern-crate.rs
Rollup merge of #56658 - Xanewok:non-panicking-file-parser, r=petrochenkov
[rust.git] / src / test / ui / unnecessary-extern-crate.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // edition:2018
12
13 #![deny(unused_extern_crates)]
14 #![feature(alloc, test, rustc_private, crate_visibility_modifier)]
15
16 extern crate libc;
17 //~^ ERROR unused extern crate
18 //~| HELP remove
19 extern crate libc as x;
20 //~^ ERROR unused extern crate
21 //~| HELP remove
22
23 extern crate proc_macro;
24
25 #[macro_use]
26 extern crate test;
27
28 pub extern crate test as y;
29
30 pub extern crate alloc;
31
32 pub(crate) extern crate alloc as a;
33
34 crate extern crate alloc as b;
35
36 mod foo {
37     pub(in crate::foo) extern crate alloc as c;
38
39     pub(super) extern crate alloc as d;
40
41     extern crate libc;
42     //~^ ERROR unused extern crate
43     //~| HELP remove
44
45     extern crate libc as x;
46     //~^ ERROR unused extern crate
47     //~| HELP remove
48
49     pub extern crate test;
50
51     pub extern crate test as y;
52
53     mod bar {
54         extern crate libc;
55         //~^ ERROR unused extern crate
56         //~| HELP remove
57
58         extern crate libc as x;
59         //~^ ERROR unused extern crate
60         //~| HELP remove
61
62         pub(in crate::foo::bar) extern crate alloc as e;
63
64         fn dummy() {
65             e::string::String::new();
66         }
67     }
68
69     fn dummy() {
70         c::string::String::new();
71         d::string::String::new();
72     }
73 }
74
75
76 fn main() {
77     a::string::String::new();
78     b::string::String::new();
79
80     proc_macro::TokenStream::new();
81 }