diff options
| author | Ralf Jung <post@ralfj.de> | 2022-12-27 12:46:08 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-02-06 11:46:37 +0100 |
| commit | ea541bc2ee00c955e3f7eb3ddd5c3ab80146ab71 (patch) | |
| tree | 90de52aa5460cb560bdc7ff4400f1c19b36db07f /tests/codegen/function-arguments.rs | |
| parent | 201ae7387245caa4591d4c8db4c35c170c64faf0 (diff) | |
| download | rust-ea541bc2ee00c955e3f7eb3ddd5c3ab80146ab71.tar.gz rust-ea541bc2ee00c955e3f7eb3ddd5c3ab80146ab71.zip | |
make &mut !Unpin not dereferenceable
See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 for discussion.
Diffstat (limited to 'tests/codegen/function-arguments.rs')
| -rw-r--r-- | tests/codegen/function-arguments.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 1f979d7b90a..0f4639086b8 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -85,6 +85,12 @@ pub fn option_nonzero_int(x: Option<NonZeroU64>) -> Option<NonZeroU64> { pub fn readonly_borrow(_: &i32) { } +// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @readonly_borrow_ret() +#[no_mangle] +pub fn readonly_borrow_ret() -> &'static i32 { + loop {} +} + // CHECK: @static_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) // static borrow may be captured #[no_mangle] @@ -115,9 +121,17 @@ pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { pub fn mutable_borrow(_: &mut i32) { } +// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @mutable_borrow_ret() +#[no_mangle] +pub fn mutable_borrow_ret() -> &'static mut i32 { + loop {} +} + #[no_mangle] -// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef align 4 dereferenceable(4) %_1) +// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef nonnull align 4 %_1) // This one is *not* `noalias` because it might be self-referential. +// It is also not `dereferenceable` due to +// <https://github.com/rust-lang/unsafe-code-guidelines/issues/381>. pub fn mutable_notunpin_borrow(_: &mut NotUnpin) { } |
