about summary refs log tree commit diff
path: root/src/test/codegen/function-arguments.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-22 21:20:35 +0000
committerbors <bors@rust-lang.org>2022-07-22 21:20:35 +0000
commit848090dcd18553b790461132ca9d2a020aeea9a2 (patch)
tree2c6acb0b99c5ff5d01f0342c601a6fe07289fd9a /src/test/codegen/function-arguments.rs
parentffa77332c630b43cb92f6256b8e404198820fa03 (diff)
parent35c6dec921d3bac70fb488db193580176f603aa1 (diff)
downloadrust-848090dcd18553b790461132ca9d2a020aeea9a2.tar.gz
rust-848090dcd18553b790461132ca9d2a020aeea9a2.zip
Auto merge of #98017 - RalfJung:dereferenceable, r=nikic
do not mark interior mutable shared refs as dereferenceable

My proposed solution to https://github.com/rust-lang/rust/issues/55005.
Diffstat (limited to 'src/test/codegen/function-arguments.rs')
-rw-r--r--src/test/codegen/function-arguments.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs
index ae6abe7a184..dda139be6fc 100644
--- a/src/test/codegen/function-arguments.rs
+++ b/src/test/codegen/function-arguments.rs
@@ -5,6 +5,7 @@
 
 use std::mem::MaybeUninit;
 use std::num::NonZeroU64;
+use std::marker::PhantomPinned;
 
 pub struct S {
   _field: [i32; 8],
@@ -14,6 +15,11 @@ pub struct UnsafeInner {
   _field: std::cell::UnsafeCell<i16>,
 }
 
+pub struct NotUnpin {
+  _field: i32,
+  _marker: PhantomPinned,
+}
+
 pub enum MyBool {
   True,
   False,
@@ -91,7 +97,7 @@ pub fn static_borrow(_: &'static i32) {
 pub fn named_borrow<'r>(_: &'r i32) {
 }
 
-// CHECK: @unsafe_borrow({{i16\*|ptr}} noundef align 2 dereferenceable(2) %_1)
+// CHECK: @unsafe_borrow({{i16\*|ptr}} noundef nonnull align 2 %_1)
 // unsafe interior means this isn't actually readonly and there may be aliases ...
 #[no_mangle]
 pub fn unsafe_borrow(_: &UnsafeInner) {
@@ -109,6 +115,18 @@ pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
 pub fn mutable_borrow(_: &mut i32) {
 }
 
+#[no_mangle]
+// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef align 4 dereferenceable(4) %_1)
+// This one is *not* `noalias` because it might be self-referential.
+pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {
+}
+
+// CHECK: @notunpin_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1)
+// But `&NotUnpin` behaves perfectly normal.
+#[no_mangle]
+pub fn notunpin_borrow(_: &NotUnpin) {
+}
+
 // CHECK: @indirect_struct({{%S\*|ptr}} noalias nocapture noundef dereferenceable(32) %_1)
 #[no_mangle]
 pub fn indirect_struct(_: S) {