]> git.lizzy.rs Git - rust.git/blob - tests/target/doc-attrib.rs
Merge pull request #3181 from scampi/issue3131
[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 //!          Example doc attribute comment with 10 leading spaces
7 #![doc(
8     html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
9     html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
10     html_root_url = "https://doc.rust-lang.org/nightly/",
11     html_playground_url = "https://play.rust-lang.org/",
12     test(attr(deny(warnings)))
13 )]
14
15 // Long `#[doc = "..."]`
16 struct A {
17     /// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
18     b: i32,
19 }
20
21 /// The `nodes` and `edges` method each return instantiations of `Cow<[T]>` to
22 /// leave implementers the freedom to create entirely new vectors or to pass
23 /// back slices into internally owned vectors.
24 struct B {
25     b: i32,
26 }
27
28 /// Level 1 comment
29 mod tests {
30     /// Level 2 comment
31     impl A {
32         /// Level 3 comment
33         fn f() {
34             /// Level 4 comment
35             fn g() {}
36         }
37     }
38 }
39
40 struct C {
41     /// item doc attrib comment
42     // regular item comment
43     b: i32,
44
45     // regular item comment
46     /// item doc attrib comment
47     c: i32,
48 }
49
50 // non-regression test for regular attributes, from #2647
51 #[cfg(
52     feature = "this_line_is_101_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
53 )]
54 pub fn foo() {}
55
56 // path attrs
57 #[clippy::bar]
58 #[clippy::bar=foo]
59 #[clippy::bar(a, b, c)]
60 pub fn foo() {}
61
62 mod issue_2620 {
63     #[derive(Debug, StructOpt)]
64     #[structopt(about = "Display information about the character on FF Logs")]
65     pub struct Params {
66         #[structopt(help = "The server the character is on")]
67         server: String,
68         #[structopt(help = "The character's first name")]
69         first_name: String,
70         #[structopt(help = "The character's last name")]
71         last_name: String,
72         #[structopt(
73             short = "j",
74             long = "job",
75             help = "The job to look at",
76             parse(try_from_str)
77         )]
78         job: Option<Job>,
79     }
80 }
81
82 // non-regression test for regular attributes, from #2969
83 #[cfg(not(all(
84     feature = "std",
85     any(
86         target_os = "linux",
87         target_os = "android",
88         target_os = "netbsd",
89         target_os = "dragonfly",
90         target_os = "haiku",
91         target_os = "emscripten",
92         target_os = "solaris",
93         target_os = "cloudabi",
94         target_os = "macos",
95         target_os = "ios",
96         target_os = "freebsd",
97         target_os = "openbsd",
98         target_os = "bitrig",
99         target_os = "redox",
100         target_os = "fuchsia",
101         windows,
102         all(target_arch = "wasm32", feature = "stdweb"),
103         all(target_arch = "wasm32", feature = "wasm-bindgen"),
104     )
105 )))]
106 type Os = NoSource;
107
108 // use cases from bindgen needing precise control over leading spaces
109 /// <div rustbindgen accessor></div>
110 #[repr(C)]
111 #[derive(Debug, Default, Copy, Clone)]
112 pub struct ContradictAccessors {
113     ///<foo>no leading spaces here</foo>
114     pub mBothAccessors: ::std::os::raw::c_int,
115     /// <div rustbindgen accessor="false"></div>
116     pub mNoAccessors: ::std::os::raw::c_int,
117     /// <div rustbindgen accessor="unsafe"></div>
118     pub mUnsafeAccessors: ::std::os::raw::c_int,
119     /// <div rustbindgen accessor="immutable"></div>
120     pub mImmutableAccessor: ::std::os::raw::c_int,
121 }
122
123 /// \brief          MPI structure
124 #[repr(C)]
125 #[derive(Debug, Copy, Clone)]
126 pub struct mbedtls_mpi {
127     ///<  integer sign
128     pub s: ::std::os::raw::c_int,
129     ///<  total # of limbs
130     pub n: ::std::os::raw::c_ulong,
131     ///<  pointer to limbs
132     pub p: *mut mbedtls_mpi_uint,
133 }