]> git.lizzy.rs Git - rust.git/blob - tests/source/imports.rs
Merge pull request #2675 from flodiebold/non-modrs-mods
[rust.git] / tests / source / imports.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-error_on_line_overflow: false
3
4 // Imports.
5
6 // Long import.
7 use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
8 use exceedingly::looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{ItemA, ItemB};
9 use exceedingly::loooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{ItemA, ItemB};
10
11 use list::{
12     // Some item
13     SomeItem /* Comment */, /* Another item */ AnotherItem /* Another Comment */, // Last Item
14     LastItem
15 };
16
17 use test::{  Other          /* C   */  , /*   A   */ self  /*    B     */    };
18
19 use syntax::{self};
20 use {/* Pre-comment! */
21      Foo, Bar /* comment */};
22 use Foo::{Bar, Baz};
23 pub use syntax::ast::{Expr_, Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath};
24
25 use syntax::some::{};
26
27 use self;
28 use std::io::{self};
29 use std::io::self;
30
31 mod Foo {
32     pub use syntax::ast::{
33         ItemForeignMod,
34         ItemImpl, 
35         ItemMac,
36         ItemMod,
37         ItemStatic, 
38         ItemDefaultImpl
39     };
40
41     mod Foo2 {
42         pub use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, self, ItemDefaultImpl};
43     }
44 }
45
46 fn test() {
47 use Baz::*;
48         use Qux;
49 }
50
51 // Simple imports
52 use  foo::bar::baz as baz ;
53 use bar::quux  as    kaas;
54 use  foo;
55
56 // With aliases.
57 use foo::{self as bar, baz};
58 use foo::{self as bar};
59 use foo::{qux as bar};
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::{a, bar::{baz, qux, xxxxxxxxxxx, yyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, foo::{a, b, cxxxxxxxxxxxxx, yyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz}}, b, boo, c,};
83
84 use fooo::{baar::{foobar::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz}}, z, bar, bar::*, x, y};
85
86 // nested imports with a single sub-tree.
87 use a::{b::{c::*}};
88 use a::{b::{c::{}}};
89 use a::{b::{c::d}};
90 use a::{b::{c::{xxx, yyy, zzz}}};
91
92 // #2645
93 /// This line is not affected.
94 // This line is deleted.
95 use c;
96
97 // #2670
98 #[macro_use]
99 use imports_with_attr;