]> git.lizzy.rs Git - rust.git/blob - tests/target/imports.rs
Merge branch 'master' into imports_indent
[rust.git] / tests / target / imports.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-error_on_line_overflow: false
3
4 // Imports.
5
6 // Long import.
7 use exceedingly::loooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{
8     ItemA, ItemB,
9 };
10 use exceedingly::looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{
11     ItemA, ItemB,
12 };
13 use syntax::ast::{ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic};
14
15 use list::{
16     // Another item
17     AnotherItem, // Another Comment
18     // Last Item
19     LastItem,
20     // Some item
21     SomeItem, /* Comment */
22 };
23
24 use test::{/* A */ self /* B */, Other /* C */};
25
26 use syntax;
27 pub use syntax::ast::{Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath, Expr_};
28 use Foo::{Bar, Baz};
29 use {Bar /* comment */, /* Pre-comment! */ Foo};
30
31 use std::io;
32 use std::io;
33
34 mod Foo {
35     pub use syntax::ast::{
36         ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic,
37     };
38
39     mod Foo2 {
40         pub use syntax::ast::{
41             self, ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic,
42         };
43     }
44 }
45
46 fn test() {
47     use Baz::*;
48     use Qux;
49 }
50
51 // Simple imports
52 use bar::quux as kaas;
53 use foo;
54 use foo::bar::baz;
55
56 // With aliases.
57 use foo as bar;
58 use foo::qux as bar;
59 use foo::{self as bar, baz};
60 use foo::{baz, qux as bar};
61
62 // With absolute paths
63 use foo;
64 use foo::Bar;
65 use foo::{Bar, Baz};
66 use Foo;
67 use {Bar, Baz};
68
69 // Root globs
70 use *;
71 use *;
72
73 // spaces used to cause glob imports to disappear (#1356)
74 use super::*;
75 use foo::issue_1356::*;
76
77 // We shouldn't remove imports which have attributes attached (#1858)
78 #[cfg(unix)]
79 use self::unix::{};
80
81 // nested imports
82 use foo::{
83     a,
84     b,
85     bar::{
86         baz,
87         foo::{a, b, cxxxxxxxxxxxxx, yyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz},
88         qux,
89         xxxxxxxxxxx,
90         yyyyyyyyyyyyy,
91         zzzzzzzzzzzzzzzz,
92     },
93     boo,
94     c,
95 };
96
97 use fooo::{
98     baar::foobar::{
99         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
100         zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
101     },
102     bar,
103     bar::*,
104     x,
105     y,
106     z,
107 };
108
109 // nested imports with a single sub-tree.
110 use a::b::c::d;
111 use a::b::c::*;
112 use a::b::c::{xxx, yyy, zzz};
113
114 // #2645
115 /// This line is not affected.
116 // This line is deleted.
117 use c;