Skip to content

Commit

Permalink
Fix the fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jan 28, 2017
1 parent 18b96cf commit 962d88b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/librustc_privacy/diagnostics.rs
Expand Up @@ -119,7 +119,7 @@ E0450: r##"
A tuple constructor was invoked while some of its fields are private. Erroneous
code example:
```compile_fail,E0450
```compile_fail
mod Bar {
pub struct Foo(isize);
}
Expand Down
19 changes: 9 additions & 10 deletions src/libsyntax/symbol.rs
Expand Up @@ -140,7 +140,7 @@ macro_rules! declare_keywords {(
$(
#[allow(non_upper_case_globals)]
pub const $konst: Keyword = Keyword {
ident: ast::Ident::with_empty_ctxt(ast::Name($index))
ident: ast::Ident::with_empty_ctxt(super::Symbol($index))
};
)*
}
Expand Down Expand Up @@ -282,25 +282,24 @@ impl Encodable for InternedString {
#[cfg(test)]
mod tests {
use super::*;
use ast::Name;

#[test]
fn interner_tests() {
let mut i: Interner = Interner::new();
// first one is zero:
assert_eq!(i.intern("dog"), Name(0));
assert_eq!(i.intern("dog"), Symbol(0));
// re-use gets the same entry:
assert_eq!(i.intern ("dog"), Name(0));
assert_eq!(i.intern ("dog"), Symbol(0));
// different string gets a different #:
assert_eq!(i.intern("cat"), Name(1));
assert_eq!(i.intern("cat"), Name(1));
assert_eq!(i.intern("cat"), Symbol(1));
assert_eq!(i.intern("cat"), Symbol(1));
// dog is still at zero
assert_eq!(i.intern("dog"), Name(0));
assert_eq!(i.intern("dog"), Symbol(0));
// gensym gets 3
assert_eq!(i.gensym("zebra"), Name(2));
assert_eq!(i.gensym("zebra"), Symbol(2));
// gensym of same string gets new number :
assert_eq!(i.gensym("zebra"), Name(3));
assert_eq!(i.gensym("zebra"), Symbol(3));
// gensym of *existing* string gets new number:
assert_eq!(i.gensym("dog"), Name(4));
assert_eq!(i.gensym("dog"), Symbol(4));
}
}
7 changes: 0 additions & 7 deletions src/test/compile-fail-fulldeps/explore-issue-38412.rs
Expand Up @@ -25,21 +25,14 @@ use pub_and_stability::{Record, Trait, Tuple};
fn main() {
// Okay
let Record { .. } = Record::new();
// Okay (for now; see RFC Issue #902)
let Tuple(..) = Tuple::new();

// Okay
let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new();
// Okay (for now; see RFC Issue #902)
let Tuple(_, _, ..) = Tuple::new(); // analogous to above

let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
Record::new();
//~^^ ERROR use of unstable library feature 'unstable_undeclared'

let Tuple(_, _, _, ..) = Tuple::new(); // analogous to previous
//~^ ERROR use of unstable library feature 'unstable_undeclared'

let r = Record::new();
let t = Tuple::new();

Expand Down
21 changes: 0 additions & 21 deletions src/test/compile-fail/E0450.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/compile-fail/E0451.rs
Expand Up @@ -25,11 +25,6 @@ fn pat_match(foo: Bar::Foo) {
//~^ NOTE field `b` is private
}

fn pat_match_tuple(foo: Bar::FooTuple) {
let Bar::FooTuple(a,b) = foo; //~ ERROR E0451
//~^ NOTE field `1` is private
}

fn main() {
let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
//~^ NOTE field `b` is private
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-38412.rs
Expand Up @@ -10,7 +10,7 @@

fn main() {
let Box(a) = loop { };
//~^ ERROR field `0` of struct `std::boxed::Box` is private
//~^ ERROR expected tuple struct/variant, found struct `Box`

// (The below is a trick to allow compiler to infer a type for
// variable `a` without attempting to ascribe a type to the
Expand Down
107 changes: 52 additions & 55 deletions src/test/compile-fail/privacy5.rs
Expand Up @@ -58,83 +58,80 @@ mod a {
}

fn this_crate() {
let a = a::A(()); //~ ERROR: cannot invoke tuple struct constructor
let b = a::B(2); //~ ERROR: cannot invoke tuple struct constructor
let c = a::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
let a = a::A(()); //~ ERROR tuple struct `A` is private
let b = a::B(2); //~ ERROR tuple struct `B` is private
let c = a::C(2, 3); //~ ERROR tuple struct `C` is private
let d = a::D(4);

let a::A(()) = a; //~ ERROR: field `0` of struct `a::A` is private
let a::A(_) = a;
match a { a::A(()) => {} } //~ ERROR: field `0` of struct `a::A` is private
match a { a::A(_) => {} }

let a::B(_) = b;
let a::B(_b) = b; //~ ERROR: field `0` of struct `a::B` is private
match b { a::B(_) => {} }
match b { a::B(_b) => {} } //~ ERROR: field `0` of struct `a::B` is private
match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field `0` of struct `a::B` is private

let a::C(_, _) = c;
let a::C(_a, _) = c;
let a::C(_, _b) = c; //~ ERROR: field `1` of struct `a::C` is private
let a::C(_a, _b) = c; //~ ERROR: field `1` of struct `a::C` is private
match c { a::C(_, _) => {} }
match c { a::C(_a, _) => {} }
match c { a::C(_, _b) => {} } //~ ERROR: field `1` of struct `a::C` is private
match c { a::C(_a, _b) => {} } //~ ERROR: field `1` of struct `a::C` is private
let a::A(()) = a; //~ ERROR tuple struct `A` is private
let a::A(_) = a; //~ ERROR tuple struct `A` is private
match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private
match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private

let a::B(_) = b; //~ ERROR tuple struct `B` is private
let a::B(_b) = b; //~ ERROR tuple struct `B` is private
match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private
match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private
match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private
//~^ ERROR tuple struct `B` is private

let a::C(_, _) = c; //~ ERROR tuple struct `C` is private
let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private
let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private
let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private
match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private
match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private
match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private
match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private

let a::D(_) = d;
let a::D(_d) = d;
match d { a::D(_) => {} }
match d { a::D(_d) => {} }
match d { a::D(1) => {} a::D(_) => {} }

let a2 = a::A; //~ ERROR: cannot invoke tuple struct constructor
let b2 = a::B; //~ ERROR: cannot invoke tuple struct constructor
let c2 = a::C; //~ ERROR: cannot invoke tuple struct constructor
let a2 = a::A; //~ ERROR tuple struct `A` is private
let b2 = a::B; //~ ERROR tuple struct `B` is private
let c2 = a::C; //~ ERROR tuple struct `C` is private
let d2 = a::D;
}

fn xcrate() {
let a = other::A(()); //~ ERROR: cannot invoke tuple struct constructor
let b = other::B(2); //~ ERROR: cannot invoke tuple struct constructor
let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
let a = other::A(()); //~ ERROR tuple struct `A` is private
let b = other::B(2); //~ ERROR tuple struct `B` is private
let c = other::C(2, 3); //~ ERROR tuple struct `C` is private
let d = other::D(4);

let other::A(()) = a; //~ ERROR: field `0` of struct `other::A` is private
let other::A(_) = a;
match a { other::A(()) => {} }
//~^ ERROR: field `0` of struct `other::A` is private
match a { other::A(_) => {} }

let other::B(_) = b;
let other::B(_b) = b; //~ ERROR: field `0` of struct `other::B` is private
match b { other::B(_) => {} }
match b { other::B(_b) => {} }
//~^ ERROR: field `0` of struct `other::B` is private
match b { other::B(1) => {} other::B(_) => {} }
//~^ ERROR: field `0` of struct `other::B` is private

let other::C(_, _) = c;
let other::C(_a, _) = c;
let other::C(_, _b) = c; //~ ERROR: field `1` of struct `other::C` is private
let other::C(_a, _b) = c; //~ ERROR: field `1` of struct `other::C` is private
match c { other::C(_, _) => {} }
match c { other::C(_a, _) => {} }
match c { other::C(_, _b) => {} }
//~^ ERROR: field `1` of struct `other::C` is private
match c { other::C(_a, _b) => {} }
//~^ ERROR: field `1` of struct `other::C` is private
let other::A(()) = a; //~ ERROR tuple struct `A` is private
let other::A(_) = a; //~ ERROR tuple struct `A` is private
match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private
match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private

let other::B(_) = b; //~ ERROR tuple struct `B` is private
let other::B(_b) = b; //~ ERROR tuple struct `B` is private
match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private
match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private
match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private
//~^ ERROR tuple struct `B` is private

let other::C(_, _) = c; //~ ERROR tuple struct `C` is private
let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private
let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private
let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private
match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private
match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private
match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private
match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private

let other::D(_) = d;
let other::D(_d) = d;
match d { other::D(_) => {} }
match d { other::D(_d) => {} }
match d { other::D(1) => {} other::D(_) => {} }

let a2 = other::A; //~ ERROR: cannot invoke tuple struct constructor
let b2 = other::B; //~ ERROR: cannot invoke tuple struct constructor
let c2 = other::C; //~ ERROR: cannot invoke tuple struct constructor
let a2 = other::A; //~ ERROR tuple struct `A` is private
let b2 = other::B; //~ ERROR tuple struct `B` is private
let c2 = other::C; //~ ERROR tuple struct `C` is private
let d2 = other::D;
}

Expand Down

0 comments on commit 962d88b

Please sign in to comment.