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