Skip to content

Commit 9e8a55f

Browse files
authored
Unrolled build for #152970
Rollup merge of #152970 - RalfJung:unpin-noalias-tests, r=Mark-Simulacrum extend unpin noalias tests to cover mutable references #152946 made a change to the logic for this attribute that the test should have flagged as problematic -- but the test only checked `Box`, not `&mut`, and those have independent code paths. So extend the test to also cover `&mut`. @b-naber would be nice if you could confirm that the added tests do fail with your PR.
2 parents c78a294 + b56949b commit 9e8a55f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎tests/codegen-llvm/function-arguments.rs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,30 @@ pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {}
257257
#[no_mangle]
258258
pub fn trait_raw(_: *const dyn Drop) {}
259259

260+
// Ensure that `Box` gets `noalias` when the right traits are present, but removing *either* `Unpin`
261+
// or `UnsafeUnpin` is enough to lose the attribute.
260262
// CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
261263
#[no_mangle]
262264
pub fn trait_box(_: Box<dyn Drop + Unpin + UnsafeUnpin>) {}
263-
264-
// Ensure that removing *either* `Unpin` or `UnsafeUnpin` is enough to lose the attribute.
265265
// CHECK: @trait_box_pin1(ptr noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
266266
#[no_mangle]
267267
pub fn trait_box_pin1(_: Box<dyn Drop + Unpin>) {}
268268
// CHECK: @trait_box_pin2(ptr noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
269269
#[no_mangle]
270270
pub fn trait_box_pin2(_: Box<dyn Drop + UnsafeUnpin>) {}
271271

272+
// Same for mutable references (with a non-zero minimal size so that we also see the
273+
// `dereferenceable` disappear).
274+
// CHECK: @trait_mutref(ptr noalias noundef align 4 dereferenceable(4){{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
275+
#[no_mangle]
276+
pub fn trait_mutref(_: &mut (i32, dyn Drop + Unpin + UnsafeUnpin)) {}
277+
// CHECK: @trait_mutref_pin1(ptr noundef nonnull align 4{{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
278+
#[no_mangle]
279+
pub fn trait_mutref_pin1(_: &mut (i32, dyn Drop + Unpin)) {}
280+
// CHECK: @trait_mutref_pin2(ptr noundef nonnull align 4{{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
281+
#[no_mangle]
282+
pub fn trait_mutref_pin2(_: &mut (i32, dyn Drop + UnsafeUnpin)) {}
283+
272284
// CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1)
273285
#[no_mangle]
274286
pub fn trait_option(

0 commit comments

Comments
 (0)