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