diff options
| author | bors <bors@rust-lang.org> | 2024-01-04 21:44:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-04 21:44:14 +0000 |
| commit | f688dd684faca5b31b156fac2c6e0ae81fc9bc90 (patch) | |
| tree | cf484a3153a9260e4352de415b9e524d813d3ac1 /tests/codegen | |
| parent | 4c5ce1f0d5bf8b2ee35ff6917658ba56ef57643b (diff) | |
| parent | c505d760a6a52a07b63016e1f9635a994cd4094f (diff) | |
Auto merge of #119569 - matthiaskrgr:rollup-4packja, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #118521 (Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag) - #119026 (std::net::bind using -1 for openbsd which in turn sets it to somaxconn.) - #119195 (Make named_asm_labels lint not trigger on unicode and trigger on format args) - #119204 (macro_rules: Less hacky heuristic for using `tt` metavariable spans) - #119362 (Make `derive(Trait)` suggestion more accurate) - #119397 (Recover parentheses in range patterns) - #119417 (Uplift some miscellaneous coroutine-specific machinery into `check_closure`) - #119539 (Fix typos) - #119540 (Don't synthesize host effect args inside trait object types) - #119555 (Add codegen test for RVO on MaybeUninit) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/maybeuninit-rvo.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/codegen/maybeuninit-rvo.rs b/tests/codegen/maybeuninit-rvo.rs new file mode 100644 index 00000000000..feed513e1fb --- /dev/null +++ b/tests/codegen/maybeuninit-rvo.rs @@ -0,0 +1,33 @@ +// compile-flags: -O +#![feature(c_unwind)] +#![crate_type = "lib"] + +pub struct Foo([u8; 1000]); + +extern "C" { + fn init(p: *mut Foo); +} + +pub fn new_from_uninit() -> Foo { + // CHECK-LABEL: new_from_uninit + // CHECK-NOT: call void @llvm.memcpy. + let mut x = std::mem::MaybeUninit::uninit(); + unsafe { + init(x.as_mut_ptr()); + x.assume_init() + } +} + +extern "C-unwind" { + fn init_unwind(p: *mut Foo); +} + +pub fn new_from_uninit_unwind() -> Foo { + // CHECK-LABEL: new_from_uninit + // CHECK: call void @llvm.memcpy. + let mut x = std::mem::MaybeUninit::uninit(); + unsafe { + init_unwind(x.as_mut_ptr()); + x.assume_init() + } +} |
