Enable privacy check for enum methods.
This commit is contained in:
parent
4da1cfe923
commit
2c9922aa49
5 changed files with 59 additions and 26 deletions
|
|
@ -1,9 +1,33 @@
|
|||
#[crate_type="lib"];
|
||||
|
||||
pub struct Foo {
|
||||
pub struct Struct {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn new() -> Foo { Foo { x: 1 } }
|
||||
impl Struct {
|
||||
fn static_meth_struct() -> Struct {
|
||||
Struct { x: 1 }
|
||||
}
|
||||
|
||||
fn meth_struct(&self) -> int {
|
||||
self.x
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Enum {
|
||||
Variant1(int),
|
||||
Variant2(int)
|
||||
}
|
||||
|
||||
impl Enum {
|
||||
fn static_meth_enum() -> Enum {
|
||||
Variant2(10)
|
||||
}
|
||||
|
||||
fn meth_enum(&self) -> int {
|
||||
match *self {
|
||||
Variant1(x) |
|
||||
Variant2(x) => x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,13 @@
|
|||
extern mod xc_private_method_lib;
|
||||
|
||||
fn main() {
|
||||
let _ = xc_private_method_lib::Foo::new(); //~ ERROR function `new` is private
|
||||
// normal method on struct
|
||||
let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); //~ ERROR method `meth_struct` is private
|
||||
// static method on struct
|
||||
let _ = xc_private_method_lib::Struct::static_meth_struct(); //~ ERROR function `static_meth_struct` is private
|
||||
|
||||
// normal method on enum
|
||||
let _ = xc_private_method_lib::Variant1(20).meth_enum(); //~ ERROR method `meth_enum` is private
|
||||
// static method on enum
|
||||
let _ = xc_private_method_lib::Enum::static_meth_enum(); //~ ERROR function `static_meth_enum` is private
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue