1
Fork 0
rust/compiler/rustc_codegen_cranelift/example
Jack Wrenn 3ce35a4ec5 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 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
2024-12-07 20:50:00 +00:00
..
alloc_example.rs
alloc_system.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
arbitrary_self_types_pointers_and_wrappers.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
dst-field-align.rs
example.rs
float-minmax-pass.rs Fix the examples in cg_clif 2024-09-09 19:39:43 -07:00
gen_block_iterate.rs
issue-59326.rs
issue-72793.rs
mini_core.rs Make Copy unsafe to implement for ADTs with unsafe fields 2024-12-07 20:50:00 +00:00
mini_core_hello_world.rs various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
mod_bench.rs
neon.rs Merge commit '6d35b4c9a0' into sync_cg_clif-2024-09-22 2024-09-23 11:20:46 +00:00
raw-dylib.rs Merge commit '69b3f5a426' into sync_cg_clif-2024-08-09 2024-08-09 17:18:46 +00:00
std_example.rs Merge commit '57845a397e' into sync_cg_clif-2024-12-06 2024-12-06 12:10:30 +00:00
subslice-patterns-const-eval.rs
track-caller-attribute.rs