rust/tests/ui/attributes/inner-attrs-impl-cfg.rs
2025-06-29 15:37:33 +05:00

37 lines
669 B
Rust

//! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions.
//!
//! This test verifies that:
//! - Inner attributes can conditionally exclude entire impl blocks
//! - Regular attributes within impl blocks work independently
//! - Attribute parsing doesn't consume too eagerly
//@ run-pass
struct Foo;
impl Foo {
#![cfg(false)]
fn method(&self) -> bool {
false
}
}
impl Foo {
#![cfg(not(FALSE))]
// Check that we don't eat attributes too eagerly.
#[cfg(false)]
fn method(&self) -> bool {
false
}
fn method(&self) -> bool {
true
}
}
pub fn main() {
assert!(Foo.method());
}