]> git.lizzy.rs Git - rust.git/blob - tests/source/imports.rs
Add tests for nested imports
[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 use syntax::some::{};
25
26 use self;
27 use std::io::{self};
28 use std::io::self;
29
30 mod Foo {
31     pub use syntax::ast::{
32         ItemForeignMod,
33         ItemImpl, 
34         ItemMac,
35         ItemMod,
36         ItemStatic, 
37         ItemDefaultImpl
38     };
39
40     mod Foo2 {
41         pub use syntax::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 // nested imports with a single sub-tree.
86 use a::{b::{c::*}};
87 use a::{b::{c::{}}};
88 use a::{b::{c::d}};
89 use a::{b::{c::{xxx, yyy, zzz}}};