about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-12-10 13:51:10 +0100
committerGitHub <noreply@github.com>2024-12-10 13:51:10 +0100
commitff0a96b7dcd1ea338204bc76d5d75830e0b218fd (patch)
tree5b09333b8b8604e35cdcf493ff9c5652f8adbdc6 /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parent59392bec75e210a27025e576883e7179e3b8c6ae (diff)
parentcfee37d35872763f3af97da66081979f91141145 (diff)
downloadrust-ff0a96b7dcd1ea338204bc76d5d75830e0b218fd.tar.gz
rust-ff0a96b7dcd1ea338204bc76d5d75830e0b218fd.zip
Rollup merge of #134008 - jswrenn:unsafe-fields-copy, r=compiler-errors
Make `Copy` unsafe to implement for ADTs with `unsafe` fields

As a rule, the application of `unsafe` to a declaration requires that use-sites of that declaration also entail `unsafe`. For example, a field declared `unsafe` may only be read in the lexical context of an `unsafe` block.

For nearly all safe traits, the safety obligations of fields are explicitly discharged when they are mentioned in method definitions. For example, idiomatically implementing `Clone` (a safe trait) for a type with unsafe fields will require `unsafe` to clone those fields.

Prior to this commit, `Copy` violated this rule. The trait is marked safe, and although it has no explicit methods, its implementation permits reads of `Self`.

This commit resolves this by making `Copy` conditionally safe to implement. It remains safe to implement for ADTs without unsafe fields, but unsafe to implement for ADTs with unsafe fields.

Tracking: #132922

r? ```@compiler-errors```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions