diff options
| author | Jack Wrenn <jack@wrenn.fyi> | 2024-12-05 20:15:08 +0000 |
|---|---|---|
| committer | Jack Wrenn <jack@wrenn.fyi> | 2024-12-05 23:52:21 +0000 |
| commit | a122dde217459c1decbce3452323807154763206 (patch) | |
| tree | 30538e19e7f4f104a5b8b3fa71d6af57c4a5e11e /tests/ui/unsafe-fields/unsafe-fields-parse.rs | |
| parent | 0e98766a5478abd9a279777e55e3d3e06e1761c0 (diff) | |
| download | rust-a122dde217459c1decbce3452323807154763206.tar.gz rust-a122dde217459c1decbce3452323807154763206.zip | |
do not implement unsafe auto traits for types with unsafe fields
If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which `auto` traits are implemented. Makes progress towards #132922.
Diffstat (limited to 'tests/ui/unsafe-fields/unsafe-fields-parse.rs')
| -rw-r--r-- | tests/ui/unsafe-fields/unsafe-fields-parse.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/unsafe-fields/unsafe-fields-parse.rs b/tests/ui/unsafe-fields/unsafe-fields-parse.rs new file mode 100644 index 00000000000..67277731293 --- /dev/null +++ b/tests/ui/unsafe-fields/unsafe-fields-parse.rs @@ -0,0 +1,10 @@ +//@ compile-flags: --crate-type=lib +#![allow(incomplete_features)] +#![feature(unsafe_fields)] + +// Parse errors even *with* unsafe_fields, which would make the compiler early-exit otherwise. +enum A { + TupleLike(unsafe u32), //~ ERROR +} + +struct B(unsafe u32); //~ ERROR |
