diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs new file mode 100644 index 000000000000..9cc53386d465 --- /dev/null +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(pub_restricted, type_macros)] + +mod foo { + type T = (); + struct S1(pub(foo) (), pub(T), pub(crate) (), pub(((), T))); + struct S2(pub((foo)) ()); //~ ERROR expected one of `+` or `,`, found `(` + //~| ERROR expected one of `+`, `;`, or `where`, found `(` +} diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs new file mode 100644 index 000000000000..01466c6a85a5 --- /dev/null +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(pub_restricted, type_macros)] + +macro_rules! define_struct { + ($t:ty) => { + struct S1(pub $t); + struct S2(pub (foo) ()); + struct S3(pub $t ()); //~ ERROR expected one of `+` or `,`, found `(` + //~| ERROR expected one of `+`, `;`, or `where`, found `(` + } +} + +mod foo { + define_struct! { (foo) } +} diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs new file mode 100644 index 000000000000..ef187a1daed3 --- /dev/null +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(pub_restricted, type_macros)] + +macro_rules! define_struct { + ($t:ty) => { + struct S1(pub($t)); + struct S2(pub (foo) ()); + struct S3(pub($t) ()); //~ ERROR expected one of `+` or `,`, found `(` + //~| ERROR expected one of `+`, `;`, or `where`, found `(` + } +} + +mod foo { + define_struct! { foo } +} diff --git a/src/test/compile-fail/privacy/restricted/ty-params.rs b/src/test/compile-fail/privacy/restricted/ty-params.rs index 04d8e9833045..ab423620d686 100644 --- a/src/test/compile-fail/privacy/restricted/ty-params.rs +++ b/src/test/compile-fail/privacy/restricted/ty-params.rs @@ -17,4 +17,8 @@ macro_rules! m { struct S(T); m!{ S } //~ ERROR type or lifetime parameters in visibility path +mod foo { + struct S(pub(foo) ()); //~ ERROR type or lifetime parameters in visibility path +} + fn main() {}