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 /compiler/rustc_ty_utils/src | |
| 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 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/abi.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 884087987ce..4ee3202292a 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -256,13 +256,16 @@ fn adjust_for_rust_scalar<'tcx>( // `Box` are not necessarily dereferenceable for the entire duration of the function as // they can be deallocated at any time. Same for non-frozen shared references (see - // <https://github.com/rust-lang/rust/pull/98017>). If LLVM had a way to say - // "dereferenceable on entry" we could use it here. + // <https://github.com/rust-lang/rust/pull/98017>), and for mutable references to + // potentially self-referential types (see + // <https://github.com/rust-lang/unsafe-code-guidelines/issues/381>). If LLVM had a way + // to say "dereferenceable on entry" we could use it here. attrs.pointee_size = match kind { - PointerKind::Box | PointerKind::SharedRef { frozen: false } => Size::ZERO, - PointerKind::SharedRef { frozen: true } | PointerKind::MutableRef { .. } => { - pointee.size - } + PointerKind::Box + | PointerKind::SharedRef { frozen: false } + | PointerKind::MutableRef { unpin: false } => Size::ZERO, + PointerKind::SharedRef { frozen: true } + | PointerKind::MutableRef { unpin: true } => pointee.size, }; // The aliasing rules for `Box<T>` are still not decided, but currently we emit |
