2022-09-15 11:29:12 +10:00
|
|
|
// Regression test for #3763
|
2020-02-24 18:06:42 +09:00
|
|
|
|
2012-12-06 18:32:13 -08:00
|
|
|
mod my_mod {
|
|
|
|
pub struct MyStruct {
|
2015-01-08 21:54:35 +11:00
|
|
|
priv_field: isize
|
2012-12-06 18:32:13 -08:00
|
|
|
}
|
|
|
|
pub fn MyStruct () -> MyStruct {
|
|
|
|
MyStruct {priv_field: 4}
|
|
|
|
}
|
2013-05-31 15:17:22 -07:00
|
|
|
impl MyStruct {
|
2013-08-07 23:20:06 -04:00
|
|
|
fn happyfun(&self) {}
|
2012-12-11 19:15:12 -08:00
|
|
|
}
|
2012-12-06 18:32:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let my_struct = my_mod::MyStruct();
|
2014-04-05 19:28:01 +02:00
|
|
|
let _woohoo = (&my_struct).priv_field;
|
2020-09-02 10:40:56 +03:00
|
|
|
//~^ ERROR field `priv_field` of struct `MyStruct` is private
|
2015-02-15 09:52:21 +01:00
|
|
|
|
|
|
|
let _woohoo = (Box::new(my_struct)).priv_field;
|
2020-09-02 10:40:56 +03:00
|
|
|
//~^ ERROR field `priv_field` of struct `MyStruct` is private
|
2015-02-15 09:52:21 +01:00
|
|
|
|
2023-02-21 14:11:08 -07:00
|
|
|
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
2015-02-15 09:52:21 +01:00
|
|
|
|
2023-02-21 14:11:08 -07:00
|
|
|
(Box::new(my_struct)).happyfun(); //~ ERROR method `happyfun` is private
|
2014-04-05 19:28:01 +02:00
|
|
|
let nope = my_struct.priv_field;
|
2020-09-02 10:40:56 +03:00
|
|
|
//~^ ERROR field `priv_field` of struct `MyStruct` is private
|
2012-12-06 18:32:13 -08:00
|
|
|
}
|