diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-05 22:10:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 22:10:02 +0100 |
| commit | b08837f180697b1441d1b9bc374a044d573b83ca (patch) | |
| tree | 3bf9b6e2f7467dd6f571d3306fac22127d54223d /tests/codegen | |
| parent | 076043346d7ae779623b3d703c32bb391188d235 (diff) | |
| parent | f391c0793b443d30ef8c4d4228550439d4dbfead (diff) | |
| download | rust-b08837f180697b1441d1b9bc374a044d573b83ca.tar.gz rust-b08837f180697b1441d1b9bc374a044d573b83ca.zip | |
Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obk
only set noalias on Box with the global allocator As discovered in https://github.com/rust-lang/miri/issues/3341, `noalias` and custom allocators don't go well together. rustc can now check whether a Box uses the global allocator. This replaces the previous ad-hoc and rather unprincipled check for a zero-sized allocator. This is the rustc part of fixing that; Miri will also need a patch.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/function-arguments.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index b75c188f51a..e6e2f645714 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -2,6 +2,7 @@ #![crate_type = "lib"] #![feature(dyn_star)] #![feature(generic_nonzero)] +#![feature(allocator_api)] use std::mem::MaybeUninit; use std::num::NonZero; @@ -182,6 +183,15 @@ pub fn _box(x: Box<i32>) -> Box<i32> { x } +// With a custom allocator, it should *not* have `noalias`. (See +// <https://github.com/rust-lang/miri/issues/3341> for why.) The second argument is the allocator, +// which is a reference here that still carries `noalias` as usual. +// CHECK: @_box_custom(ptr noundef nonnull align 4 %x.0, ptr noalias noundef nonnull readonly align 1 %x.1) +#[no_mangle] +pub fn _box_custom(x: Box<i32, &std::alloc::Global>) { + drop(x) +} + // CHECK: noundef nonnull align 4 ptr @notunpin_box(ptr noundef nonnull align 4 %x) #[no_mangle] pub fn notunpin_box(x: Box<NotUnpin>) -> Box<NotUnpin> { |
