granite-rust/tests/ui/issues/issue-3763.rs

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

30 lines
857 B
Rust
Raw Normal View History

// compile-flags: -Zsave-analysis
2020-02-25 00:21:45 +09:00
// Also regression test for #69416
2012-12-06 18:32:13 -08:00
mod my_mod {
pub struct MyStruct {
priv_field: isize
2012-12-06 18:32:13 -08:00
}
pub fn MyStruct () -> MyStruct {
MyStruct {priv_field: 4}
}
impl MyStruct {
2013-08-07 23:20:06 -04:00
fn happyfun(&self) {}
}
2012-12-06 18:32:13 -08:00
}
fn main() {
let my_struct = my_mod::MyStruct();
let _woohoo = (&my_struct).priv_field;
//~^ ERROR field `priv_field` of struct `MyStruct` is private
let _woohoo = (Box::new(my_struct)).priv_field;
//~^ ERROR field `priv_field` of struct `MyStruct` is private
2020-03-04 21:03:15 -06:00
(&my_struct).happyfun(); //~ ERROR associated function `happyfun` is private
2020-03-04 21:03:15 -06:00
(Box::new(my_struct)).happyfun(); //~ ERROR associated function `happyfun` is private
let nope = my_struct.priv_field;
//~^ ERROR field `priv_field` of struct `MyStruct` is private
2012-12-06 18:32:13 -08:00
}