@@ -40,12 +40,12 @@ macro_rules! cfg_if {
40
40
41
41
// Internal and recursive macro to emit all the items
42
42
//
43
- // Collects all the negated cfgs in a list at the beginning and after the
43
+ // Collects all the negated `cfg`s in a list at the beginning and after the
44
44
// semicolon is all the remaining items
45
45
( @__items ( $( $not: meta, ) * ) ; ) => { } ;
46
46
( @__items ( $( $not: meta, ) * ) ; ( ( $( $m: meta) ,* ) ( $( $it: item) * ) ) ,
47
47
$( $rest: tt) * ) => {
48
- // Emit all items within one block, applying an approprate #[cfg]. The
48
+ // Emit all items within one block, applying an appropriate #[cfg]. The
49
49
// #[cfg] will require all `$m` matchers specified and must also negate
50
50
// all previous matchers.
51
51
cfg_if! { @__apply cfg( all( $( $m, ) * not( any( $( $not) ,* ) ) ) ) , $( $it) * }
@@ -169,27 +169,28 @@ macro_rules! s_paren {
169
169
// so we need to avoid emitting it at all of 'const-extern-fn'.
170
170
//
171
171
// Specifically, moving the 'cfg_if' into the macro body will *not* work.
172
- // Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emiited
172
+ // Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emitted
173
173
// into user code. The 'cfg' gate will not stop Rust from trying to parse the
174
174
// 'pub const unsafe extern fn', so users would get a compiler error even when
175
175
// the 'const-extern-fn' feature is disabled
176
176
//
177
177
// Note that users of this macro need to place 'const' in a weird position
178
178
// (after the closing ')' for the arguments, but before the return type).
179
179
// This was the only way I could satisfy the following two requirements:
180
- // 1. Avoid ambuguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn'
180
+ // 1. Avoid ambiguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn'
181
181
// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same
182
182
// 'f!' block
183
183
cfg_if ! {
184
184
if #[ cfg( libc_const_extern_fn) ] {
185
185
#[ allow( unused_macros) ]
186
186
macro_rules! f {
187
- ( $( pub $( { $constness: ident} ) * fn $i: ident(
187
+ ( $( $ ( # [ $attr : meta ] ) * pub $( { $constness: ident} ) * fn $i: ident(
188
188
$( $arg: ident: $argty: ty) , *
189
189
) -> $ret: ty {
190
190
$( $body: stmt) ; *
191
191
} ) * ) => ( $(
192
192
#[ inline]
193
+ $( #[ $attr] ) *
193
194
pub $( $constness) * unsafe extern fn $i( $( $arg: $argty) , *
194
195
) -> $ret {
195
196
$( $body) ; *
@@ -199,12 +200,13 @@ cfg_if! {
199
200
200
201
#[ allow( unused_macros) ]
201
202
macro_rules! safe_f {
202
- ( $( pub $( { $constness: ident} ) * fn $i: ident(
203
+ ( $( $ ( # [ $attr : meta ] ) * pub $( { $constness: ident} ) * fn $i: ident(
203
204
$( $arg: ident: $argty: ty) , *
204
205
) -> $ret: ty {
205
206
$( $body: stmt) ; *
206
207
} ) * ) => ( $(
207
208
#[ inline]
209
+ $( #[ $attr] ) *
208
210
pub $( $constness) * extern fn $i( $( $arg: $argty) , *
209
211
) -> $ret {
210
212
$( $body) ; *
@@ -214,12 +216,13 @@ cfg_if! {
214
216
215
217
#[ allow( unused_macros) ]
216
218
macro_rules! const_fn {
217
- ( $( $( { $constness: ident} ) * fn $i: ident(
219
+ ( $( $( # [ $attr : meta ] ) * $ ( { $constness: ident} ) * fn $i: ident(
218
220
$( $arg: ident: $argty: ty) , *
219
221
) -> $ret: ty {
220
222
$( $body: stmt) ; *
221
223
} ) * ) => ( $(
222
224
#[ inline]
225
+ $( #[ $attr] ) *
223
226
$( $constness) * fn $i( $( $arg: $argty) , *
224
227
) -> $ret {
225
228
$( $body) ; *
@@ -230,12 +233,13 @@ cfg_if! {
230
233
} else {
231
234
#[ allow( unused_macros) ]
232
235
macro_rules! f {
233
- ( $( pub $( { $constness: ident} ) * fn $i: ident(
236
+ ( $( $ ( # [ $attr : meta ] ) * pub $( { $constness: ident} ) * fn $i: ident(
234
237
$( $arg: ident: $argty: ty) , *
235
238
) -> $ret: ty {
236
239
$( $body: stmt) ; *
237
240
} ) * ) => ( $(
238
241
#[ inline]
242
+ $( #[ $attr] ) *
239
243
pub unsafe extern fn $i( $( $arg: $argty) , *
240
244
) -> $ret {
241
245
$( $body) ; *
@@ -245,12 +249,13 @@ cfg_if! {
245
249
246
250
#[ allow( unused_macros) ]
247
251
macro_rules! safe_f {
248
- ( $( pub $( { $constness: ident} ) * fn $i: ident(
252
+ ( $( $ ( # [ $attr : meta ] ) * pub $( { $constness: ident} ) * fn $i: ident(
249
253
$( $arg: ident: $argty: ty) , *
250
254
) -> $ret: ty {
251
255
$( $body: stmt) ; *
252
256
} ) * ) => ( $(
253
257
#[ inline]
258
+ $( #[ $attr] ) *
254
259
pub extern fn $i( $( $arg: $argty) , *
255
260
) -> $ret {
256
261
$( $body) ; *
@@ -260,12 +265,13 @@ cfg_if! {
260
265
261
266
#[ allow( unused_macros) ]
262
267
macro_rules! const_fn {
263
- ( $( $( { $constness: ident} ) * fn $i: ident(
268
+ ( $( $( # [ $attr : meta ] ) * $ ( { $constness: ident} ) * fn $i: ident(
264
269
$( $arg: ident: $argty: ty) , *
265
270
) -> $ret: ty {
266
271
$( $body: stmt) ; *
267
272
} ) * ) => ( $(
268
273
#[ inline]
274
+ $( #[ $attr] ) *
269
275
fn $i( $( $arg: $argty) , *
270
276
) -> $ret {
271
277
$( $body) ; *
0 commit comments