rust/tests/ui/conditional-compilation/cfg_accessible.rs

56 lines
1.0 KiB
Rust
Raw Normal View History

#![feature(cfg_accessible)]
mod m {
pub struct ExistingPublic;
struct ExistingPrivate;
}
2022-05-20 14:27:34 -05:00
trait Trait {
type Assoc;
}
enum Enum {
Existing,
}
#[cfg_accessible(Enum)]
struct ExistingResolved;
#[cfg_accessible(Enum::Existing)]
struct ExistingResolvedVariant;
#[cfg_accessible(m::ExistingPublic)]
struct ExistingPublic;
2022-05-20 14:27:34 -05:00
#[cfg_accessible(m::ExistingPrivate)]
struct ExistingPrivate;
2022-05-20 14:27:34 -05:00
#[cfg_accessible(m::NonExistent)]
struct NonExistingPrivate;
#[cfg_accessible(n::AccessibleExpanded)] // OK, `cfg_accessible` can wait and retry.
struct AccessibleExpanded;
2022-05-20 14:27:34 -05:00
#[cfg_accessible(Trait::Assoc)]
struct AccessibleTraitAssoc;
macro_rules! generate_accessible_expanded {
() => {
mod n {
pub struct AccessibleExpanded;
}
};
}
generate_accessible_expanded!();
fn main() {
ExistingPublic;
AccessibleExpanded;
2022-05-20 14:27:34 -05:00
AccessibleTraitAssoc;
ExistingPrivate; //~ ERROR cannot find
NonExistingPrivate; //~ ERROR cannot find
NonExistingTraitAlias; //~ ERROR cannot find
}