rust/compiler/rustc_codegen_gcc/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 Fix compilation errors in rustc_codegen_gcc examples 2023-11-02 21:03:27 +01:00
alloc_system.rs Remove libc dependency in cg_gcc alloc_system example 2023-11-02 21:03:27 +01:00
arbitrary_self_types_pointers_and_wrappers.rs Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
dst-field-align.rs Add 'compiler/rustc_codegen_gcc/' from commit 'afae271d5d3719eeb92c18bc004bb6d1965a5f3f' 2021-08-12 21:53:49 -04:00
example.rs Merge commit '98ed962c7d3eebe12c97588e61245273d265e72f' into master 2024-07-10 12:44:23 +02:00
mini_core_hello_world.rs stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
mini_core.rs Make Copy unsafe to implement for ADTs with unsafe fields 2024-12-07 20:50:00 +00:00
mod_bench.rs Fix compilation errors in rustc_codegen_gcc examples 2023-11-02 21:03:27 +01:00
std_example.rs stabilize is_sorted 2024-07-28 03:11:54 +08:00
subslice-patterns-const-eval.rs Add 'compiler/rustc_codegen_gcc/' from commit 'afae271d5d3719eeb92c18bc004bb6d1965a5f3f' 2021-08-12 21:53:49 -04:00
track-caller-attribute.rs Add 'compiler/rustc_codegen_gcc/' from commit 'afae271d5d3719eeb92c18bc004bb6d1965a5f3f' 2021-08-12 21:53:49 -04:00