about summary refs log tree commit diff
path: root/tests/codegen/function-arguments.rs
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-12-30 21:11:30 +0100
committernils <48135649+Nilstrieb@users.noreply.github.com>2023-01-17 16:23:22 +0100
commitf1255380ac1cb7be1b6b0ac0eda5b1274b29eff6 (patch)
tree4b0add72699a923fde3a2c7801330403a369c6ca /tests/codegen/function-arguments.rs
parentaf23ad93cd3309e90ccb2c49b7a7b2ac913e0d06 (diff)
downloadrust-f1255380ac1cb7be1b6b0ac0eda5b1274b29eff6.tar.gz
rust-f1255380ac1cb7be1b6b0ac0eda5b1274b29eff6.zip
Add more codegen tests
Diffstat (limited to 'tests/codegen/function-arguments.rs')
-rw-r--r--tests/codegen/function-arguments.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs
index 20519978a0d..1f979d7b90a 100644
--- a/tests/codegen/function-arguments.rs
+++ b/tests/codegen/function-arguments.rs
@@ -1,11 +1,11 @@
 // compile-flags: -O -C no-prepopulate-passes
 
 #![crate_type = "lib"]
-#![feature(rustc_attrs)]
 
 use std::mem::MaybeUninit;
 use std::num::NonZeroU64;
 use std::marker::PhantomPinned;
+use std::ptr::NonNull;
 
 pub struct S {
   _field: [i32; 8],
@@ -138,11 +138,27 @@ pub fn indirect_struct(_: S) {
 pub fn borrowed_struct(_: &S) {
 }
 
+// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x)
+#[no_mangle]
+pub fn option_borrow(x: Option<&i32>) {
+}
+
+// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x)
+#[no_mangle]
+pub fn option_borrow_mut(x: Option<&mut i32>) {
+}
+
 // CHECK: @raw_struct({{%S\*|ptr}} noundef %_1)
 #[no_mangle]
 pub fn raw_struct(_: *const S) {
 }
 
+// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1)
+#[no_mangle]
+pub fn raw_option_nonnull_struct(_: Option<NonNull<S>>) {
+}
+
+
 // `Box` can get deallocated during execution of the function, so it should
 // not get `dereferenceable`.
 // CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x)
@@ -200,6 +216,16 @@ pub fn str(_: &[u8]) {
 pub fn trait_borrow(_: &dyn Drop) {
 }
 
+// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
+#[no_mangle]
+pub fn option_trait_borrow(x: Option<&dyn Drop>) {
+}
+
+// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
+#[no_mangle]
+pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {
+}
+
 // CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
 #[no_mangle]
 pub fn trait_raw(_: *const dyn Drop) {