make &mut !Unpin not dereferenceable
See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 for discussion.
This commit is contained in:
parent
201ae73872
commit
ea541bc2ee
6 changed files with 48 additions and 67 deletions
|
@ -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]
|
||||
// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef align 4 dereferenceable(4) %_1)
|
||||
pub fn mutable_borrow_ret() -> &'static mut i32 {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
// 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) {
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue