2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-01-07 20:53:58 -06:00
|
|
|
#![feature(box_syntax)]
|
2013-12-12 01:17:54 -06:00
|
|
|
|
2012-12-06 20:32:13 -06:00
|
|
|
mod my_mod {
|
|
|
|
pub struct MyStruct {
|
2015-01-08 04:54:35 -06:00
|
|
|
priv_field: isize
|
2012-12-06 20:32:13 -06:00
|
|
|
}
|
|
|
|
pub fn MyStruct () -> MyStruct {
|
|
|
|
MyStruct {priv_field: 4}
|
|
|
|
}
|
2013-05-31 17:17:22 -05:00
|
|
|
impl MyStruct {
|
2013-08-07 22:20:06 -05:00
|
|
|
fn happyfun(&self) {}
|
2012-12-11 21:15:12 -06:00
|
|
|
}
|
2012-12-06 20:32:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let my_struct = my_mod::MyStruct();
|
2014-04-05 12:28:01 -05:00
|
|
|
let _woohoo = (&my_struct).priv_field;
|
|
|
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
2014-05-05 20:56:44 -05:00
|
|
|
let _woohoo = (box my_struct).priv_field;
|
2014-04-05 12:28:01 -05:00
|
|
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
2012-12-11 21:15:12 -06:00
|
|
|
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
2014-05-05 20:56:44 -05:00
|
|
|
(box my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
2014-04-05 12:28:01 -05:00
|
|
|
let nope = my_struct.priv_field;
|
|
|
|
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
2012-12-06 20:32:13 -06:00
|
|
|
}
|