From 104aaa44e8506cfaf2c00d6ca35dce93a8228545 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 25 Mar 2014 15:59:33 -0700 Subject: [PATCH] rustc: Relax restriction on privacy for fields This is a necessary change in preparation for switching the defaults as part of #8122. RFC: 0004-private-fields --- src/librustc/middle/privacy.rs | 4 ---- src/test/compile-fail/struct-field-privacy.rs | 2 +- .../compile-fail/struct-variant-privacy.rs | 20 ------------------- 3 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 src/test/compile-fail/struct-variant-privacy.rs diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 0c2abfd23c3d..d46cb7218b80 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -1001,10 +1001,6 @@ impl<'a> SanePrivacyVisitor<'a> { }; for f in def.fields.iter() { match f.node.kind { - ast::NamedField(_, ast::Public) if public_def => { - tcx.sess.span_err(f.span, "unnecessary `pub` \ - visibility"); - } ast::NamedField(_, ast::Private) if !public_def => { tcx.sess.span_err(f.span, "unnecessary `priv` \ visibility"); diff --git a/src/test/compile-fail/struct-field-privacy.rs b/src/test/compile-fail/struct-field-privacy.rs index d298d331a3f8..56c58590fba3 100644 --- a/src/test/compile-fail/struct-field-privacy.rs +++ b/src/test/compile-fail/struct-field-privacy.rs @@ -25,7 +25,7 @@ mod inner { pub struct B { a: int, priv b: int, - pub c: int, //~ ERROR: unnecessary `pub` visibility + pub c: int, } } diff --git a/src/test/compile-fail/struct-variant-privacy.rs b/src/test/compile-fail/struct-variant-privacy.rs deleted file mode 100644 index f37e02be12cb..000000000000 --- a/src/test/compile-fail/struct-variant-privacy.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#[feature(struct_variant)]; - -pub enum Foo { - Bar { - pub x: int, //~ ERROR unnecessary `pub` visibility - y: int, - priv z: int - } -} - -fn main() {}