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

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

29 lines
791 B
Rust
Raw Normal View History

// Regression test for #3763
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
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
(Box::new(my_struct)).happyfun(); //~ ERROR method `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
}