]> git.lizzy.rs Git - rust.git/blob - tests/target/doc-attrib.rs
Merge pull request #2816 from moxian/enum-discrim
[rust.git] / tests / target / doc-attrib.rs
1 // rustfmt-wrap_comments: true
2 // rustfmt-normalize_doc_attributes: true
3
4 // Only doc = "" attributes should be normalized
5 //! Example doc attribute comment
6 #![doc(
7     html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
8     html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
9     html_root_url = "https://doc.rust-lang.org/nightly/",
10     html_playground_url = "https://play.rust-lang.org/",
11     test(attr(deny(warnings)))
12 )]
13
14 // Long `#[doc = "..."]`
15 struct A {
16     /// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
17     b: i32,
18 }
19
20 /// The `nodes` and `edges` method each return instantiations of `Cow<[T]>` to
21 /// leave implementers the freedom to create entirely new vectors or to pass
22 /// back slices into internally owned vectors.
23 struct B {
24     b: i32,
25 }
26
27 /// Level 1 comment
28 mod tests {
29     /// Level 2 comment
30     impl A {
31         /// Level 3 comment
32         fn f() {
33             /// Level 4 comment
34             fn g() {}
35         }
36     }
37 }
38
39 struct C {
40     /// item doc attrib comment
41     // regular item comment
42     b: i32,
43
44     // regular item comment
45     /// item doc attrib comment
46     c: i32,
47 }
48
49 // non-regression test for regular attributes, from #2647
50 #[cfg(
51     feature = "this_line_is_101_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
52 )]
53 pub fn foo() {}
54
55 // path attrs
56 #[clippy::bar]
57 #[clippy::bar=foo]
58 #[clippy::bar(a, b, c)]
59 pub fn foo() {}
60
61 mod issue_2620 {
62     #[derive(Debug, StructOpt)]
63     #[structopt(about = "Display information about the character on FF Logs")]
64     pub struct Params {
65         #[structopt(help = "The server the character is on")]
66         server: String,
67         #[structopt(help = "The character's first name")]
68         first_name: String,
69         #[structopt(help = "The character's last name")]
70         last_name: String,
71         #[structopt(
72             short = "j",
73             long = "job",
74             help = "The job to look at",
75             parse(try_from_str)
76         )]
77         job: Option<Job>,
78     }
79 }
80
81 // non-regression test for regular attributes, from #2969
82 #[cfg(not(all(
83     feature = "std",
84     any(
85         target_os = "linux",
86         target_os = "android",
87         target_os = "netbsd",
88         target_os = "dragonfly",
89         target_os = "haiku",
90         target_os = "emscripten",
91         target_os = "solaris",
92         target_os = "cloudabi",
93         target_os = "macos",
94         target_os = "ios",
95         target_os = "freebsd",
96         target_os = "openbsd",
97         target_os = "bitrig",
98         target_os = "redox",
99         target_os = "fuchsia",
100         windows,
101         all(target_arch = "wasm32", feature = "stdweb"),
102         all(target_arch = "wasm32", feature = "wasm-bindgen"),
103     )
104 )))]
105 type Os = NoSource;