Skip to content

Commit 70a664d

Browse files
committed
cleanup: Remove the const_fn! macro
Now that is okay for functions to be always `const`, this macro doesn't add anything other than the `#[inline]` attribute, which isn't useful for private functions anyway. Thus, remove the macro and leave its contents wherever it is used. (backport <rust-lang#4714>) (cherry picked from commit dcde5cd)
1 parent b398805 commit 70a664d

File tree

11 files changed

+26
-60
lines changed

11 files changed

+26
-60
lines changed

src/macros.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,6 @@ macro_rules! safe_f {
331331
)+};
332332
}
333333

334-
/// Define a nonpublic function.
335-
macro_rules! const_fn {
336-
($(
337-
$(#[$attr:meta])*
338-
const fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
339-
$body:block
340-
)*) => ($(
341-
#[inline]
342-
$(#[$attr])*
343-
const fn $i($($arg: $argty),*) -> $ret
344-
$body
345-
)*)
346-
}
347-
348334
macro_rules! __item {
349335
($i:item) => {
350336
$i

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,10 +1419,8 @@ pub const RTAX_MPLS2: c_int = 9;
14191419
pub const RTAX_MPLS3: c_int = 10;
14201420
pub const RTAX_MAX: c_int = 11;
14211421

1422-
const_fn! {
1423-
const fn _CMSG_ALIGN(n: usize) -> usize {
1424-
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)
1425-
}
1422+
const fn _CMSG_ALIGN(n: usize) -> usize {
1423+
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)
14261424
}
14271425

14281426
f! {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,10 +4749,8 @@ pub const fn MAP_ALIGNED(a: c_int) -> c_int {
47494749
a << 24
47504750
}
47514751

4752-
const_fn! {
4753-
const fn _ALIGN(p: usize) -> usize {
4754-
(p + _ALIGNBYTES) & !_ALIGNBYTES
4755-
}
4752+
const fn _ALIGN(p: usize) -> usize {
4753+
(p + _ALIGNBYTES) & !_ALIGNBYTES
47564754
}
47574755

47584756
f! {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,10 +2301,8 @@ pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK;
23012301
pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY;
23022302
pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR;
23032303

2304-
const_fn! {
2305-
const fn _ALIGN(p: usize) -> usize {
2306-
(p + _ALIGNBYTES) & !_ALIGNBYTES
2307-
}
2304+
const fn _ALIGN(p: usize) -> usize {
2305+
(p + _ALIGNBYTES) & !_ALIGNBYTES
23082306
}
23092307

23102308
f! {

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,10 +1868,8 @@ pub const RTAX_STATIC: c_int = 13;
18681868
pub const RTAX_SEARCH: c_int = 14;
18691869
pub const RTAX_MAX: c_int = 15;
18701870

1871-
const_fn! {
1872-
const fn _ALIGN(p: usize) -> usize {
1873-
(p + _ALIGNBYTES) & !_ALIGNBYTES
1874-
}
1871+
const fn _ALIGN(p: usize) -> usize {
1872+
(p + _ALIGNBYTES) & !_ALIGNBYTES
18751873
}
18761874

18771875
f! {

src/unix/cygwin/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,10 +1928,8 @@ safe_f! {
19281928
}
19291929
}
19301930

1931-
const_fn! {
1932-
const fn CMSG_ALIGN(len: usize) -> usize {
1933-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
1934-
}
1931+
const fn CMSG_ALIGN(len: usize) -> usize {
1932+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
19351933
}
19361934

19371935
extern "C" {

src/unix/haiku/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,10 +1514,8 @@ pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10;
15141514
pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20;
15151515
pub const POSIX_SPAWN_SETSID: c_int = 0x40;
15161516

1517-
const_fn! {
1518-
const fn CMSG_ALIGN(len: usize) -> usize {
1519-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
1520-
}
1517+
const fn CMSG_ALIGN(len: usize) -> usize {
1518+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
15211519
}
15221520

15231521
f! {

src/unix/hurd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,10 +3414,8 @@ pub const PTHREAD_STACK_MIN: size_t = 0;
34143414
// Non-public helper constants
34153415
const _UTSNAME_LENGTH: usize = 1024;
34163416

3417-
const_fn! {
3418-
const fn CMSG_ALIGN(len: usize) -> usize {
3419-
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
3420-
}
3417+
const fn CMSG_ALIGN(len: usize) -> usize {
3418+
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
34213419
}
34223420

34233421
// functions

src/unix/linux_like/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,10 +1784,8 @@ cfg_if! {
17841784
}
17851785
}
17861786

1787-
const_fn! {
1788-
const fn CMSG_ALIGN(len: usize) -> usize {
1789-
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
1790-
}
1787+
const fn CMSG_ALIGN(len: usize) -> usize {
1788+
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
17911789
}
17921790

17931791
f! {

src/unix/nto/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,14 +2607,12 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
26072607
__spare: 0,
26082608
};
26092609

2610-
const_fn! {
2611-
const fn _CMSG_ALIGN(len: usize) -> usize {
2612-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
2613-
}
2610+
const fn _CMSG_ALIGN(len: usize) -> usize {
2611+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
2612+
}
26142613

2615-
const fn _ALIGN(p: usize, b: usize) -> usize {
2616-
(p + b - 1) & !(b - 1)
2617-
}
2614+
const fn _ALIGN(p: usize, b: usize) -> usize {
2615+
(p + b - 1) & !(b - 1)
26182616
}
26192617

26202618
f! {

0 commit comments

Comments
 (0)