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