Skip to content

Commit 2d0d474

Browse files
committed
Auto merge of #1958 - JohnTitor:fix-dragonfly-build, r=nagisa
Allow `deprecated` attribute on `f!` macros to fix dragonfly build Fixes #1957 cc `@nagisa` I think this should resolve the build :)
2 parents 6ca151e + d371bdc commit 2d0d474

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/macros.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ macro_rules! cfg_if {
4040

4141
// Internal and recursive macro to emit all the items
4242
//
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
4444
// semicolon is all the remaining items
4545
(@__items ($($not:meta,)*) ; ) => {};
4646
(@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
4747
$($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
4949
// #[cfg] will require all `$m` matchers specified and must also negate
5050
// all previous matchers.
5151
cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
@@ -169,27 +169,28 @@ macro_rules! s_paren {
169169
// so we need to avoid emitting it at all of 'const-extern-fn'.
170170
//
171171
// 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
173173
// into user code. The 'cfg' gate will not stop Rust from trying to parse the
174174
// 'pub const unsafe extern fn', so users would get a compiler error even when
175175
// the 'const-extern-fn' feature is disabled
176176
//
177177
// Note that users of this macro need to place 'const' in a weird position
178178
// (after the closing ')' for the arguments, but before the return type).
179179
// 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'
181181
// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same
182182
// 'f!' block
183183
cfg_if! {
184184
if #[cfg(libc_const_extern_fn)] {
185185
#[allow(unused_macros)]
186186
macro_rules! f {
187-
($(pub $({$constness:ident})* fn $i:ident(
187+
($($(#[$attr:meta])* pub $({$constness:ident})* fn $i:ident(
188188
$($arg:ident: $argty:ty),*
189189
) -> $ret:ty {
190190
$($body:stmt);*
191191
})*) => ($(
192192
#[inline]
193+
$(#[$attr])*
193194
pub $($constness)* unsafe extern fn $i($($arg: $argty),*
194195
) -> $ret {
195196
$($body);*
@@ -199,12 +200,13 @@ cfg_if! {
199200

200201
#[allow(unused_macros)]
201202
macro_rules! safe_f {
202-
($(pub $({$constness:ident})* fn $i:ident(
203+
($($(#[$attr:meta])* pub $({$constness:ident})* fn $i:ident(
203204
$($arg:ident: $argty:ty),*
204205
) -> $ret:ty {
205206
$($body:stmt);*
206207
})*) => ($(
207208
#[inline]
209+
$(#[$attr])*
208210
pub $($constness)* extern fn $i($($arg: $argty),*
209211
) -> $ret {
210212
$($body);*
@@ -214,12 +216,13 @@ cfg_if! {
214216

215217
#[allow(unused_macros)]
216218
macro_rules! const_fn {
217-
($($({$constness:ident})* fn $i:ident(
219+
($($(#[$attr:meta])* $({$constness:ident})* fn $i:ident(
218220
$($arg:ident: $argty:ty),*
219221
) -> $ret:ty {
220222
$($body:stmt);*
221223
})*) => ($(
222224
#[inline]
225+
$(#[$attr])*
223226
$($constness)* fn $i($($arg: $argty),*
224227
) -> $ret {
225228
$($body);*
@@ -230,12 +233,13 @@ cfg_if! {
230233
} else {
231234
#[allow(unused_macros)]
232235
macro_rules! f {
233-
($(pub $({$constness:ident})* fn $i:ident(
236+
($($(#[$attr:meta])* pub $({$constness:ident})* fn $i:ident(
234237
$($arg:ident: $argty:ty),*
235238
) -> $ret:ty {
236239
$($body:stmt);*
237240
})*) => ($(
238241
#[inline]
242+
$(#[$attr])*
239243
pub unsafe extern fn $i($($arg: $argty),*
240244
) -> $ret {
241245
$($body);*
@@ -245,12 +249,13 @@ cfg_if! {
245249

246250
#[allow(unused_macros)]
247251
macro_rules! safe_f {
248-
($(pub $({$constness:ident})* fn $i:ident(
252+
($($(#[$attr:meta])* pub $({$constness:ident})* fn $i:ident(
249253
$($arg:ident: $argty:ty),*
250254
) -> $ret:ty {
251255
$($body:stmt);*
252256
})*) => ($(
253257
#[inline]
258+
$(#[$attr])*
254259
pub extern fn $i($($arg: $argty),*
255260
) -> $ret {
256261
$($body);*
@@ -260,12 +265,13 @@ cfg_if! {
260265

261266
#[allow(unused_macros)]
262267
macro_rules! const_fn {
263-
($($({$constness:ident})* fn $i:ident(
268+
($($(#[$attr:meta])* $({$constness:ident})* fn $i:ident(
264269
$($arg:ident: $argty:ty),*
265270
) -> $ret:ty {
266271
$($body:stmt);*
267272
})*) => ($(
268273
#[inline]
274+
$(#[$attr])*
269275
fn $i($($arg: $argty),*
270276
) -> $ret {
271277
$($body);*

src/unix/bsd/freebsdlike/dragonfly/errno.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// DragonFlyBSD's __error function is declared with "static inline", so it must
22
// be implemented in the libc crate, as a pointer to a static thread_local.
33
f! {
4-
#[deprecated(since = "0.2.77", "Use `__errno_location()` instead")]
4+
#[deprecated(since = "0.2.77", note = "Use `__errno_location()` instead")]
55
pub fn __error() -> *mut ::c_int {
66
&mut errno
77
}

0 commit comments

Comments
 (0)