]> git.lizzy.rs Git - rust.git/blob - tests/source/attrib.rs
Merge pull request #1669 from topecongiro/issue-1668
[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 }