
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.
10 lines
271 B
Rust
10 lines
271 B
Rust
//@ 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
|