rust/tests/ui/feature-gates/feature-gate-unsafe_fields.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
588 B
Rust
Raw Normal View History

//@ compile-flags: --crate-type=lib
//@ revisions: with_gate without_gate
//@ [with_gate] check-pass
#![cfg_attr(with_gate, feature(unsafe_fields))] //[with_gate]~ WARNING
#[cfg(any())]
struct Foo {
unsafe field: (), //[without_gate]~ ERROR
}
// This should not parse as an unsafe field definition.
struct FooTuple(unsafe fn());
#[cfg(any())]
enum Bar {
Variant { unsafe field: () }, //[without_gate]~ ERROR
// This should not parse as an unsafe field definition.
VariantTuple(unsafe fn()),
}
#[cfg(any())]
union Baz {
unsafe field: (), //[without_gate]~ ERROR
}