]> git.lizzy.rs Git - rust.git/blob - tests/target/attrib.rs
7ff79b164117bc0609ca8ea41756ff6c8dbe2839
[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)]
49     foo: usize,
50 }
51
52 // #1668
53
54 /// Default path (*nix)
55 #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
56 fn foo() {
57     #[cfg(target_os = "freertos")]
58     match port_id {
59         'a' | 'A' => GpioPort {
60             port_address: GPIO_A,
61         },
62         'b' | 'B' => GpioPort {
63             port_address: GPIO_B,
64         },
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 }