about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorRobin Raymond <robin@robinraymond.de>2022-06-19 10:36:26 +0000
committerRobin Raymond <robin@robinraymond.de>2022-06-19 10:38:17 +0000
commitcb20e252aded0a8b66cc7164b42a16883925b4b5 (patch)
treeb5a5995ce293289fb48e052257076f1094d3fce8 /src/test/codegen
parent09d937ed5f26888154c499fa97f8c45c691c9a31 (diff)
downloadrust-cb20e252aded0a8b66cc7164b42a16883925b4b5.tar.gz
rust-cb20e252aded0a8b66cc7164b42a16883925b4b5.zip
Add test to verify noalias is not being added
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/noalias-rwlockreadguard.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/codegen/noalias-rwlockreadguard.rs b/src/test/codegen/noalias-rwlockreadguard.rs
new file mode 100644
index 00000000000..48e4d46b589
--- /dev/null
+++ b/src/test/codegen/noalias-rwlockreadguard.rs
@@ -0,0 +1,14 @@
+// compile-flags: -O -C no-prepopulate-passes -Z mutable-noalias=yes
+
+#![crate_type = "lib"]
+
+use std::cell::UnsafeCell;
+use std::sync::RwLockReadGuard;
+
+// Make sure that `RwLockReadGuard` does not get a `noalias` attribute, because
+// the `UnsafeCell` might alias writes after it is dropped.
+
+// CHECK-LABEL: @maybe_aliased(
+// CHECK-NOT: noalias
+#[no_mangle]
+pub unsafe fn maybe_aliased(_: RwLockReadGuard<'_, i32>, _data: &UnsafeCell<i32>) {}