Fix the fallout
This commit is contained in:
parent
18b96cf286
commit
962d88b5ee
@ -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);
|
||||
}
|
||||
|
@ -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))
|
||||
};
|
||||
)*
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
mod Bar {
|
||||
pub struct Foo( bool, pub i32, f32, bool);
|
||||
//~^ NOTE private field declared here
|
||||
//~| NOTE private field declared here
|
||||
//~| NOTE private field declared here
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = Bar::Foo(false,1,0.1, true); //~ ERROR E0450
|
||||
//~^ NOTE cannot construct with a private field
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -58,30 +58,31 @@ 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::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;
|
||||
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::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;
|
||||
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::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;
|
||||
@ -89,42 +90,38 @@ fn this_crate() {
|
||||
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::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;
|
||||
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::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;
|
||||
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::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;
|
||||
@ -132,9 +129,9 @@ fn xcrate() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user