diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-18 22:44:36 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-21 20:10:53 +0100 |
| commit | c3f9403f590ac8989bc50f933541a6234e391747 (patch) | |
| tree | 5db68e298e1c9b88e7613ce48d3f561079e58cdc /src/test/codegen | |
| parent | 08c5ffd4a3e79aeb9a4cc79576d97760a9be25de (diff) | |
| download | rust-c3f9403f590ac8989bc50f933541a6234e391747.tar.gz rust-c3f9403f590ac8989bc50f933541a6234e391747.zip | |
Don't consider !Unpin references as noalias
Such structures may contain self-references, in which case the same location may be accessible through a pointer that is not based-on the noalias pointer. This is still grey area as far as language semantics are concerned, but checking for !Unpin as an indicator for self-referential sturctures seems like a good approach for the meantime.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/noalias-unpin.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/codegen/noalias-unpin.rs b/src/test/codegen/noalias-unpin.rs new file mode 100644 index 00000000000..46f18d7f891 --- /dev/null +++ b/src/test/codegen/noalias-unpin.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z mutable-noalias=yes + +#![crate_type = "lib"] + +pub struct SelfRef { + self_ref: *mut SelfRef, + _pin: std::marker::PhantomPinned +} + +// CHECK-LABEL: @test_self_ref( +// CHECK-NOT: noalias +#[no_mangle] +pub unsafe fn test_self_ref(s: &mut SelfRef) { + (*s.self_ref).self_ref = std::ptr::null_mut(); +} |
