@@ -167,40 +167,31 @@ macro_rules! e {
167
167
) * ) ;
168
168
}
169
169
170
- // This is a pretty horrible hack to allow us to conditionally mark
171
- // some functions as 'const', without requiring users of this macro
172
- // to care about the "const-extern-fn" feature.
170
+ // This is a pretty horrible hack to allow us to conditionally mark some functions as 'const',
171
+ // without requiring users of this macro to care "libc_const_extern_fn".
173
172
//
174
- // When 'const-extern-fn ' is enabled, we emit the captured 'const' keyword
175
- // in the expanded function.
173
+ // When 'libc_const_extern_fn ' is enabled, we emit the captured 'const' keyword in the expanded
174
+ // function.
176
175
//
177
- // When 'const-extern-fn ' is disabled, we always emit a plain 'pub unsafe extern fn'.
176
+ // When 'libc_const_extern_fn ' is disabled, we always emit a plain 'pub unsafe extern fn'.
178
177
// Note that the expression matched by the macro is exactly the same - this allows
179
- // users of this macro to work whether or not 'const-extern-fn ' is enabled
178
+ // users of this macro to work whether or not 'libc_const_extern_fn ' is enabled
180
179
//
181
180
// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks.
182
181
// This is because 'const unsafe extern fn' won't even parse on older compilers,
183
- // so we need to avoid emitting it at all of 'const-extern-fn '.
182
+ // so we need to avoid emitting it at all of 'libc_const_extern_fn '.
184
183
//
185
- // Specifically, moving the 'cfg_if' into the macro body will *not* work.
186
- // Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emitted
187
- // into user code. The 'cfg' gate will not stop Rust from trying to parse the
188
- // 'pub const unsafe extern fn', so users would get a compiler error even when
189
- // the 'const-extern-fn' feature is disabled
190
- //
191
- // Note that users of this macro need to place 'const' in a weird position
192
- // (after the closing ')' for the arguments, but before the return type).
193
- // This was the only way I could satisfy the following two requirements:
194
- // 1. Avoid ambiguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn'
195
- // 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same
196
- // 'f!' block
184
+ // Specifically, moving the 'cfg_if' into the macro body will *not* work. Doing so would cause the
185
+ // '#[cfg(libc_const_extern_fn)]' to be emitted into user code. The 'cfg' gate will not stop Rust
186
+ // from trying to parse the 'pub const unsafe extern fn', so users would get a compiler error even
187
+ // when the 'libc_const_extern_fn' feature is disabled.
197
188
198
189
// FIXME(ctest): ctest can't handle `const extern` functions, we should be able to remove this
199
190
// cfg completely.
200
191
// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct.
201
192
cfg_if ! {
202
- if #[ cfg( feature = "const-extern-fn" ) ] {
203
- /// Define an `unsafe` function that is const as long as `const-extern-fn ` is enabled.
193
+ if #[ cfg( libc_const_extern_fn ) ] {
194
+ /// Define an `unsafe` function that is const as long as `libc_const_extern_fn ` is enabled.
204
195
macro_rules! f {
205
196
( $(
206
197
$( #[ $attr: meta] ) *
@@ -214,7 +205,7 @@ cfg_if! {
214
205
) * )
215
206
}
216
207
217
- /// Define a safe function that is const as long as `const-extern-fn ` is enabled.
208
+ /// Define a safe function that is const as long as `libc_const_extern_fn ` is enabled.
218
209
macro_rules! safe_f {
219
210
( $(
220
211
$( #[ $attr: meta] ) *
@@ -228,7 +219,7 @@ cfg_if! {
228
219
) * )
229
220
}
230
221
231
- /// A nonpublic function that is const as long as `const-extern-fn ` is enabled.
222
+ /// A nonpublic function that is const as long as `libc_const_extern_fn ` is enabled.
232
223
macro_rules! const_fn {
233
224
( $(
234
225
$( #[ $attr: meta] ) *
@@ -242,7 +233,7 @@ cfg_if! {
242
233
) * )
243
234
}
244
235
} else {
245
- /// Define an `unsafe` function that is const as long as `const-extern-fn ` is enabled.
236
+ /// Define an `unsafe` function that is const as long as `libc_const_extern_fn ` is enabled.
246
237
macro_rules! f {
247
238
( $(
248
239
$( #[ $attr: meta] ) *
@@ -256,7 +247,7 @@ cfg_if! {
256
247
) * )
257
248
}
258
249
259
- /// Define a safe function that is const as long as `const-extern-fn ` is enabled.
250
+ /// Define a safe function that is const as long as `libc_const_extern_fn ` is enabled.
260
251
macro_rules! safe_f {
261
252
( $(
262
253
$( #[ $attr: meta] ) *
@@ -270,7 +261,7 @@ cfg_if! {
270
261
) * )
271
262
}
272
263
273
- /// A nonpublic function that is const as long as `const-extern-fn ` is enabled.
264
+ /// A nonpublic function that is const as long as `libc_const_extern_fn ` is enabled.
274
265
macro_rules! const_fn {
275
266
( $(
276
267
$( #[ $attr: meta] ) *
0 commit comments