rust/tests/ui/pub/pub-restricted.rs
Lukas Wirth eae7fe1bdb Use non-2015 edition paths in tests that do not test for their resolution
This allows for testing these tests on editions other than 2015
2025-06-03 13:35:31 +02:00

32 lines
814 B
Rust

mod a {}
pub (a) fn afn() {} //~ ERROR incorrect visibility restriction
pub (b) fn bfn() {} //~ ERROR incorrect visibility restriction
pub (crate::a) fn cfn() {} //~ ERROR incorrect visibility restriction
pub fn privfn() {}
mod x {
mod y {
pub (in crate::x) fn foo() {}
pub (super) fn bar() {}
pub (crate) fn qux() {}
}
}
mod y {
struct Foo {
pub (crate) c: usize,
pub (super) s: usize,
valid_private: usize,
pub (in crate::y) valid_in_x: usize,
pub (a) invalid: usize, //~ ERROR incorrect visibility restriction
pub (in crate::x) non_parent_invalid: usize, //~ ERROR visibilities can only be restricted
}
}
fn main() {}
// test multichar names
mod xyz {}
pub (xyz) fn xyz() {} //~ ERROR incorrect visibility restriction