mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
![]() As a rule, the application of `unsafe` to a declaration requires that use-sites of that declaration also require `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 |
||
---|---|---|
.. | ||
alloc_example.rs | ||
alloc_system.rs | ||
arbitrary_self_types_pointers_and_wrappers.rs | ||
dst-field-align.rs | ||
example.rs | ||
mini_core_hello_world.rs | ||
mini_core.rs | ||
mod_bench.rs | ||
std_example.rs | ||
subslice-patterns-const-eval.rs | ||
track-caller-attribute.rs |