]> git.lizzy.rs Git - rust.git/blob - tests/source/attrib.rs
Update tests
[rust.git] / tests / source / attrib.rs
1 // rustfmt-wrap_comments: true
2 // Test attributes and doc comments are preserved.
3
4 /// Blah blah blah.
5 /// Blah blah blah.
6 /// Blah blah blah.
7 /// Blah blah blah.
8
9 /// Blah blah blah.
10 impl Bar {
11     /// Blah blah blooo.
12     /// Blah blah blooo.
13     /// Blah blah blooo.
14     /// Blah blah blooo.
15     #[an_attribute]
16     fn foo(&mut self) -> isize {
17     }
18
19     /// Blah blah bing.
20     /// Blah blah bing.
21     /// Blah blah bing.
22
23
24     /// Blah blah bing.
25     /// Blah blah bing.
26     /// Blah blah bing.
27     pub fn f2(self) {
28         (foo, bar)
29     }
30
31     #[another_attribute]
32     fn f3(self) -> Dog {
33     }
34
35     /// Blah blah bing.
36
37     #[attrib1]
38     /// Blah blah bing.
39     #[attrib2]
40     // Another comment that needs rewrite because it's tooooooooooooooooooooooooooooooo loooooooooooong.
41     /// Blah blah bing.
42     fn f4(self) -> Cat {
43     }
44
45     // We want spaces around `=`
46     #[cfg(feature="nightly")]
47     fn f5(self) -> Monkey {}
48 }
49
50 // #984
51 struct Foo {
52     # [ derive ( Clone , PartialEq , Debug , Deserialize , Serialize ) ]
53     foo: usize,
54 }
55
56 // #1668
57
58 /// Default path (*nix)
59 #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
60 fn foo() {
61     #[cfg(target_os = "freertos")]
62     match port_id {
63         'a' | 'A' => GpioPort { port_address: GPIO_A },
64         'b' | 'B' => GpioPort { port_address: GPIO_B },
65         _ => panic!(),
66     }
67
68     #[cfg_attr(not(target_os = "freertos"), allow(unused_variables))]
69     let x = 3;
70 }
71
72 // #1777
73 #[test]
74 #[should_panic(expected = "(")]
75 #[should_panic(expected = /* ( */ "(")]
76 #[should_panic(/* ((((( */expected /* ((((( */= /* ((((( */ "("/* ((((( */)]
77 #[should_panic(
78     /* (((((((( *//*
79     (((((((((()(((((((( */
80     expected = "("
81     // ((((((((
82 )]
83 fn foo() {}
84
85 // #1799
86 fn issue_1799() {
87     #[allow(unreachable_code)] // https://github.com/rust-lang/rust/issues/43336
88     Some( Err(error) ) ;
89
90     #[allow(unreachable_code)]
91     // https://github.com/rust-lang/rust/issues/43336
92     Some( Err(error) ) ;
93 }
94
95 // Formatting inner attributes
96 fn inner_attributes() {
97     #![ this_is_an_inner_attribute ( foo ) ]
98
99     foo();
100 }
101
102 impl InnerAttributes() {
103     #![ this_is_an_inner_attribute ( foo ) ]
104
105     fn foo() {}
106 }
107
108 mod InnerAttributes {
109     #![ this_is_an_inner_attribute ( foo ) ]
110 }