]> git.lizzy.rs Git - rust.git/blob - tests/target/imports.rs
Merge pull request #2677 from csmoe/remove_nested_parens_opt
[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, b,
84     bar::{
85         baz, foo::{a, b, cxxxxxxxxxxxxx, yyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz}, qux, xxxxxxxxxxx,
86         yyyyyyyyyyyyy, zzzzzzzzzzzzzzzz,
87     },
88     boo, c,
89 };
90
91 use fooo::{
92     baar::foobar::{
93         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
94         zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
95     },
96     bar, bar::*, x, y, z,
97 };
98
99 // nested imports with a single sub-tree.
100 use a::b::c::d;
101 use a::b::c::*;
102 use a::b::c::{xxx, yyy, zzz};
103
104 // #2645
105 /// This line is not affected.
106 // This line is deleted.
107 use c;