First stage of struct variant field visibility changes
We need a snapshot before the parser can be adjusted.
This commit is contained in:
parent
b80edf1d12
commit
00741a2c27
10 changed files with 94 additions and 69 deletions
|
|
@ -15,7 +15,7 @@ pub struct BTree<V> {
|
|||
}
|
||||
|
||||
pub enum TreeItem<V> {
|
||||
TreeLeaf { pub value: V },
|
||||
TreeLeaf { value: V },
|
||||
}
|
||||
|
||||
pub fn leaf<V>(value: V) -> TreeItem<V> {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@
|
|||
// <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.
|
||||
|
||||
#![feature(struct_variant)]
|
||||
|
||||
pub enum Foo {
|
||||
Bar {
|
||||
baz: int
|
||||
}
|
||||
enum Bar {
|
||||
Baz { a: int }
|
||||
}
|
||||
|
||||
|
|
@ -15,5 +15,5 @@
|
|||
|
||||
pub enum Enum {
|
||||
Variant(u8),
|
||||
StructVariant { pub arg: u8 }
|
||||
StructVariant { arg: u8 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
// aux-build:privacy-struct-variant.rs
|
||||
|
||||
#![feature(struct_variant)]
|
||||
|
||||
extern crate "privacy-struct-variant" as other;
|
||||
|
||||
mod a {
|
||||
pub enum Foo {
|
||||
Bar {
|
||||
baz: int
|
||||
}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
let foo = Bar { baz: 42 };
|
||||
|
||||
let Bar { baz: _ } = foo;
|
||||
match foo { Bar { baz: _ } => {} }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let foo = a::Bar { baz: 42 };
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
|
||||
|
||||
let a::Bar { baz: _ } = foo;
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
|
||||
match foo { a::Bar { baz: _ } => {} }
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `a::Foo` is private
|
||||
//
|
||||
let foo = other::Bar { baz: 42 };
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `privacy-struct-variant::Foo` is private
|
||||
|
||||
let other::Bar { baz: _ } = foo;
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `privacy-struct-variant::Foo` is private
|
||||
match foo { other::Bar { baz: _ } => {} }
|
||||
//~^ ERROR: field `baz` of variant `Bar` of enum `privacy-struct-variant::Foo` is private
|
||||
}
|
||||
23
src/test/compile-fail/struct-variant-privacy-xc.rs
Normal file
23
src/test/compile-fail/struct-variant-privacy-xc.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
// aux-build:struct_variant_privacy.rs
|
||||
#![feature(struct_variant)]
|
||||
|
||||
extern crate struct_variant_privacy;
|
||||
|
||||
fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private
|
||||
match b {
|
||||
struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR variant `Baz` is private
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
25
src/test/compile-fail/struct-variant-privacy.rs
Normal file
25
src/test/compile-fail/struct-variant-privacy.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2014 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.
|
||||
#![feature(struct_variant)]
|
||||
|
||||
mod foo {
|
||||
enum Bar {
|
||||
Baz { a: int }
|
||||
}
|
||||
}
|
||||
|
||||
fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private
|
||||
match b {
|
||||
foo::Bar::Baz { a: _a } => {} //~ ERROR variant `Baz` is inaccessible
|
||||
// ^~ ERROR enum `Bar` is private
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
#[deny(dead_code)]
|
||||
pub enum Foo {
|
||||
Bar {
|
||||
pub baz: int
|
||||
baz: int
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/test/run-pass/struct-variant-field-visibility.rs
Normal file
25
src/test/run-pass/struct-variant-field-visibility.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
#![feature(struct_variant)]
|
||||
|
||||
mod foo {
|
||||
pub enum Foo {
|
||||
Bar { a: int }
|
||||
}
|
||||
}
|
||||
|
||||
fn f(f: foo::Foo) {
|
||||
match f {
|
||||
foo::Foo::Bar { a: _a } => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue