]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/source/fn-param-attributes.rs
Rollup merge of #107166 - petrochenkov:nooptable, r=oli-obk
[rust.git] / src / tools / rustfmt / tests / source / fn-param-attributes.rs
1 // https://github.com/rust-lang/rustfmt/issues/3623
2
3 fn foo(#[cfg(something)] x: i32, y: i32) -> i32 {
4     x + y
5 }
6
7 fn foo_b(#[cfg(something)]x: i32, y: i32) -> i32 {
8     x + y
9 }
10
11 fn add(#[cfg(something)]#[deny(C)]  x: i32, y: i32) -> i32 {
12     x + y
13 }
14
15 struct NamedSelfRefStruct {}
16 impl NamedSelfRefStruct {
17     fn foo(
18 #[cfg(something)]  self: &Self,
19     ) {}
20 }
21
22 struct MutStruct {}
23 impl MutStruct {
24     fn foo(
25         #[cfg(foo)]&mut self,#[deny(C)] b: i32,
26     ) {}
27 }
28
29 fn main() {
30     let c = |
31         #[allow(C)]a: u32,
32         #[cfg(something)] b: i32,
33         #[cfg_attr(something, cfg(nothing))]#[deny(C)] c: i32,
34     | {};
35     let _ = c(1, 2);
36 }
37
38 pub fn bar(
39     /// bar
40 #[test] a: u32,
41     /// Bar
42             #[must_use]
43 /// Baz
44     #[no_mangle] b: i32,
45 ) {}
46
47
48 fn abc(
49     #[foo]
50     #[bar] param: u32,
51 ) {
52     // ...
53 }
54
55 fn really_really_really_loooooooooooooooooooong(#[cfg(some_even_longer_config_feature_that_keeps_going_and_going_and_going_forever_and_ever_and_ever_on_and_on)] b: i32) {
56     // ...
57 }