]> git.proxmox.com Git - rustc.git/blob - tests/ui/underscore-imports/basic.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / underscore-imports / basic.rs
1 // check-pass
2 // aux-build:underscore-imports.rs
3
4 #![warn(unused_imports, unused_extern_crates)]
5
6 #[macro_use]
7 extern crate underscore_imports as _;
8
9 do_nothing!(); // OK
10
11 struct S;
12
13 mod m {
14 pub trait Tr1 {
15 fn tr1_is_in_scope(&self) {}
16 }
17 pub trait Tr2 {
18 fn tr2_is_in_scope(&self) {}
19 }
20
21 impl Tr1 for ::S {}
22 impl Tr2 for ::S {}
23 }
24
25 mod unused {
26 use m::Tr1 as _; //~ WARN unused import
27 use S as _; //~ WARN unused import
28 extern crate core as _; // OK
29 }
30
31 mod outer {
32 mod middle {
33 pub use m::Tr1 as _;
34 pub use m::Tr2 as _; // OK, no name conflict
35 struct Tr1; // OK, no name conflict
36 fn check() {
37 // Both traits are in scope
38 ::S.tr1_is_in_scope();
39 ::S.tr2_is_in_scope();
40 }
41
42 mod inner {
43 // `_` imports are fetched by glob imports
44 use super::*;
45 fn check() {
46 // Both traits are in scope
47 ::S.tr1_is_in_scope();
48 ::S.tr2_is_in_scope();
49 }
50 }
51 }
52
53 // `_` imports are fetched by glob imports
54 use self::middle::*;
55 fn check() {
56 // Both traits are in scope
57 ::S.tr1_is_in_scope();
58 ::S.tr2_is_in_scope();
59 }
60 }
61
62 fn main() {}