diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/consts/auxiliary | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/consts/auxiliary')
-rw-r--r-- | tests/ui/consts/auxiliary/cci_const_block.rs | 6 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/closure-in-foreign-crate.rs | 8 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/const_fn_lib.rs | 22 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/external_macro.rs | 14 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/issue-17718-aux.rs | 10 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/issue-63226.rs | 14 | ||||
-rw-r--r-- | tests/ui/consts/auxiliary/promotable_const_fn_lib.rs | 23 |
7 files changed, 97 insertions, 0 deletions
diff --git a/tests/ui/consts/auxiliary/cci_const_block.rs b/tests/ui/consts/auxiliary/cci_const_block.rs new file mode 100644 index 000000000..ad618aab8 --- /dev/null +++ b/tests/ui/consts/auxiliary/cci_const_block.rs @@ -0,0 +1,6 @@ +pub static BLOCK_FN_DEF: fn(usize) -> usize = { + fn foo(a: usize) -> usize { + a + 10 + } + foo +}; diff --git a/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs b/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs new file mode 100644 index 000000000..edc7fa81a --- /dev/null +++ b/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs @@ -0,0 +1,8 @@ +#![crate_type = "lib"] +#![feature(const_closures, const_trait_impl)] +#![allow(incomplete_features)] + +pub const fn test() { + let cl = const || {}; + cl(); +} diff --git a/tests/ui/consts/auxiliary/const_fn_lib.rs b/tests/ui/consts/auxiliary/const_fn_lib.rs new file mode 100644 index 000000000..88cea60e1 --- /dev/null +++ b/tests/ui/consts/auxiliary/const_fn_lib.rs @@ -0,0 +1,22 @@ +// Crate that exports a const fn. Used for testing cross-crate. + +#![crate_type="rlib"] + +pub const fn foo() -> usize { 22 } + +pub const fn bar() -> fn() { + fn x() {} + x +} + +#[inline] +pub const fn bar_inlined() -> fn() { + fn x() {} + x +} + +#[inline(always)] +pub const fn bar_inlined_always() -> fn() { + fn x() {} + x +} diff --git a/tests/ui/consts/auxiliary/external_macro.rs b/tests/ui/consts/auxiliary/external_macro.rs new file mode 100644 index 000000000..d260634c9 --- /dev/null +++ b/tests/ui/consts/auxiliary/external_macro.rs @@ -0,0 +1,14 @@ +#![feature(allow_internal_unstable)] + +// Macro to help ensure CONST_ERR lint errors +// are not silenced in external macros. +// https://github.com/rust-lang/rust/issues/65300 + +#[macro_export] +#[allow_internal_unstable(type_ascription)] +macro_rules! static_assert { + ($test:expr) => { + #[allow(dead_code)] + const _: () = [()][!($test: bool) as usize]; + } +} diff --git a/tests/ui/consts/auxiliary/issue-17718-aux.rs b/tests/ui/consts/auxiliary/issue-17718-aux.rs new file mode 100644 index 000000000..91abdbff8 --- /dev/null +++ b/tests/ui/consts/auxiliary/issue-17718-aux.rs @@ -0,0 +1,10 @@ +use std::sync::atomic; + +pub const C1: usize = 1; +pub const C2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); +pub const C3: fn() = { fn foo() {} foo }; +pub const C4: usize = C1 * C1 + C1 / C1; +pub const C5: &'static usize = &C4; + +pub static S1: usize = 3; +pub static S2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); diff --git a/tests/ui/consts/auxiliary/issue-63226.rs b/tests/ui/consts/auxiliary/issue-63226.rs new file mode 100644 index 000000000..2dc9539ba --- /dev/null +++ b/tests/ui/consts/auxiliary/issue-63226.rs @@ -0,0 +1,14 @@ +pub struct VTable{ + state:extern "C" fn(), +} + +impl VTable{ + pub const fn vtable()->&'static VTable{ + Self::VTABLE + } + + const VTABLE: &'static VTable = + &VTable{state}; +} + +extern "C" fn state() {} diff --git a/tests/ui/consts/auxiliary/promotable_const_fn_lib.rs b/tests/ui/consts/auxiliary/promotable_const_fn_lib.rs new file mode 100644 index 000000000..b1d5440b4 --- /dev/null +++ b/tests/ui/consts/auxiliary/promotable_const_fn_lib.rs @@ -0,0 +1,23 @@ +// Crate that exports a const fn. Used for testing cross-crate. + +#![feature(staged_api, rustc_attrs)] +#![stable(since="1.0.0", feature = "mep")] + +#![crate_type="rlib"] + +#[rustc_promotable] +#[stable(since="1.0.0", feature = "mep")] +#[rustc_const_stable(since="1.0.0", feature = "mep")] +#[inline] +pub const fn foo() -> usize { 22 } + +#[stable(since="1.0.0", feature = "mep")] +pub struct Foo(usize); + +impl Foo { + #[stable(since="1.0.0", feature = "mep")] + #[rustc_const_stable(feature = "mep", since = "1.0.0")] + #[inline] + #[rustc_promotable] + pub const fn foo() -> usize { 22 } +} |