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/const-blocks/migrate-pass.rs | |
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/const-blocks/migrate-pass.rs')
-rw-r--r-- | tests/ui/consts/const-blocks/migrate-pass.rs | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/ui/consts/const-blocks/migrate-pass.rs b/tests/ui/consts/const-blocks/migrate-pass.rs new file mode 100644 index 000000000..fd66f5aa6 --- /dev/null +++ b/tests/ui/consts/const-blocks/migrate-pass.rs @@ -0,0 +1,125 @@ +// check-pass +#![allow(warnings)] + +// Some type that is not copyable. +struct Bar; + +mod constants { + use Bar; + + fn no_impl_copy_empty_value_no_elements() { + const FOO: Option<Bar> = None; + const ARR: [Option<Bar>; 0] = [FOO; 0]; + } + + fn no_impl_copy_empty_value_single_element() { + const FOO: Option<Bar> = None; + const ARR: [Option<Bar>; 1] = [FOO; 1]; + } + + fn no_impl_copy_empty_value_multiple_elements() { + const FOO: Option<Bar> = None; + const ARR: [Option<Bar>; 2] = [FOO; 2]; + } + + fn no_impl_copy_value_no_elements() { + const FOO: Option<Bar> = Some(Bar); + const ARR: [Option<Bar>; 0] = [FOO; 0]; + } + + fn no_impl_copy_value_single_element() { + const FOO: Option<Bar> = Some(Bar); + const ARR: [Option<Bar>; 1] = [FOO; 1]; + } + + fn no_impl_copy_value_multiple_elements() { + const FOO: Option<Bar> = Some(Bar); + const ARR: [Option<Bar>; 2] = [FOO; 2]; + } + + fn impl_copy_empty_value_no_elements() { + const FOO: Option<u32> = None; + const ARR: [Option<u32>; 0] = [FOO; 0]; + } + + fn impl_copy_empty_value_one_element() { + const FOO: Option<u32> = None; + const ARR: [Option<u32>; 1] = [FOO; 1]; + } + + fn impl_copy_empty_value_multiple_elements() { + const FOO: Option<u32> = None; + const ARR: [Option<u32>; 2] = [FOO; 2]; + } + + fn impl_copy_value_no_elements() { + const FOO: Option<u32> = Some(4); + const ARR: [Option<u32>; 0] = [FOO; 0]; + } + + fn impl_copy_value_one_element() { + const FOO: Option<u32> = Some(4); + const ARR: [Option<u32>; 1] = [FOO; 1]; + } + + fn impl_copy_value_multiple_elements() { + const FOO: Option<u32> = Some(4); + const ARR: [Option<u32>; 2] = [FOO; 2]; + } +} + +mod non_constants { + use Bar; + + fn no_impl_copy_empty_value_no_elements() { + let x = None; + let arr: [Option<Bar>; 0] = [x; 0]; + } + + fn no_impl_copy_empty_value_single_element() { + let x = None; + let arr: [Option<Bar>; 1] = [x; 1]; + } + + fn no_impl_copy_value_no_elements() { + let x = Some(Bar); + let arr: [Option<Bar>; 0] = [x; 0]; + } + + fn no_impl_copy_value_single_element() { + let x = Some(Bar); + let arr: [Option<Bar>; 1] = [x; 1]; + } + + fn impl_copy_empty_value_no_elements() { + let x: Option<u32> = None; + let arr: [Option<u32>; 0] = [x; 0]; + } + + fn impl_copy_empty_value_one_element() { + let x: Option<u32> = None; + let arr: [Option<u32>; 1] = [x; 1]; + } + + fn impl_copy_empty_value_multiple_elements() { + let x: Option<u32> = None; + let arr: [Option<u32>; 2] = [x; 2]; + } + + fn impl_copy_value_no_elements() { + let x: Option<u32> = Some(4); + let arr: [Option<u32>; 0] = [x; 0]; + } + + fn impl_copy_value_one_element() { + let x: Option<u32> = Some(4); + let arr: [Option<u32>; 1] = [x; 1]; + } + + fn impl_copy_value_multiple_elements() { + let x: Option<u32> = Some(4); + let arr: [Option<u32>; 2] = [x; 2]; + } +} + +fn main() {} |