Skip to content

Commit 7ec6ad3

Browse files
committed
library: use const_block_items feature
1 parent 1e0e6cf commit 7ec6ad3

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

library/core/src/ffi/va_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ impl<'f> Drop for VaListImpl<'f> {
302302

303303
// Checks (via an assert in `compiler/rustc_ty_utils/src/abi.rs`) that the C ABI for the current
304304
// target correctly implements `rustc_pass_indirectly_in_non_rustic_abis`.
305-
const _: () = {
305+
const {
306306
#[repr(C)]
307307
#[rustc_pass_indirectly_in_non_rustic_abis]
308308
struct Type(usize);
309309

310310
const extern "C" fn c(_: Type) {}
311311

312312
c(Type(0))
313-
};
313+
}

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
#![feature(cfg_target_has_atomic)]
145145
#![feature(cfg_target_has_atomic_equal_alignment)]
146146
#![feature(cfg_ub_checks)]
147+
#![feature(const_block_items)]
147148
#![feature(const_precise_live_drops)]
148149
#![feature(const_trait_impl)]
149150
#![feature(decl_macro)]

library/core/src/ptr/alignment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::{cmp, fmt, hash, mem, num};
1515
pub struct Alignment(AlignmentEnum);
1616

1717
// Alignment is `repr(usize)`, but via extra steps.
18-
const _: () = assert!(size_of::<Alignment>() == size_of::<usize>());
19-
const _: () = assert!(align_of::<Alignment>() == align_of::<usize>());
18+
const { assert!(size_of::<Alignment>() == size_of::<usize>()) }
19+
const { assert!(align_of::<Alignment>() == align_of::<usize>()) }
2020

2121
fn _alignment_can_be_structurally_matched(a: Alignment) -> bool {
2222
matches!(a, Alignment::MIN)

library/coretests/tests/cmp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ mod const_cmp {
238238
}
239239
}
240240

241-
const _: () = assert!(S(1) == S(1));
242-
const _: () = assert!(S(0) != S(1));
241+
const { assert!(S(1) == S(1)) }
242+
const { assert!(S(0) != S(1)) }
243243

244-
const _: () = assert!(S(1) <= S(1));
245-
const _: () = assert!(S(1) >= S(1));
246-
const _: () = assert!(S(0) < S(1));
247-
const _: () = assert!(S(1) > S(0));
244+
const { assert!(S(1) <= S(1)) }
245+
const { assert!(S(1) >= S(1)) }
246+
const { assert!(S(0) < S(1)) }
247+
const { assert!(S(1) > S(0)) }
248248
}

library/coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![feature(char_internals)]
1717
#![feature(char_max_len)]
1818
#![feature(clone_to_uninit)]
19+
#![feature(const_block_items)]
1920
#![feature(const_cell_traits)]
2021
#![feature(const_cmp)]
2122
#![feature(const_convert)]

library/std/src/sys/pal/sgx/libunwind_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::{slice, str};
99
// Verify that the byte pattern libunwind uses to initialize an RwLock is
1010
// equivalent to the value of RwLock::new(). If the value changes,
1111
// `src/UnwindRustSgx.h` in libunwind needs to be changed too.
12-
const _: () = unsafe {
13-
let bits_rust: usize = crate::mem::transmute(RwLock::new());
12+
const {
13+
let bits_rust: usize = unsafe { crate::mem::transmute(RwLock::new()) };
1414
assert!(bits_rust == 0);
1515
};
1616

library/std/tests/sync/barrier.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn test_barrier() {
3838
/// Asserts that `Barrier` is ref unwind safe.
3939
///
4040
/// See <https://github.com/rust-lang/rust/issues/146087>.
41-
const _: () = {
41+
const {
4242
const fn check_ref_unwind_safe<T: RefUnwindSafe>() {}
4343
check_ref_unwind_safe::<Barrier>();
44-
};
44+
}

library/std/tests/sync/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(const_block_items)]
12
#![feature(lazy_get)]
23
#![feature(mapped_lock_guards)]
34
#![feature(mpmc_channel)]

0 commit comments

Comments
 (0)