From dcd4621b4df9c1962ea55653e3f01cdf8b6a3e12 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 2 Apr 2016 02:22:41 +0000 Subject: [PATCH] Add test for #30079 --- src/test/compile-fail/issue-30079.rs | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/compile-fail/issue-30079.rs diff --git a/src/test/compile-fail/issue-30079.rs b/src/test/compile-fail/issue-30079.rs new file mode 100644 index 0000000000000..a8db01b82da94 --- /dev/null +++ b/src/test/compile-fail/issue-30079.rs @@ -0,0 +1,55 @@ +// 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(rustc_attrs)] +#![allow(unused)] + +struct SemiPriv; + +mod m1 { + struct Priv; + impl ::SemiPriv { + pub fn f(_: Priv) {} //~ WARN private type in public interface + //~^ WARNING hard error + } + + impl Priv { + pub fn f(_: Priv) {} // ok + } +} + +mod m2 { + struct Priv; + impl ::std::ops::Deref for ::SemiPriv { + type Target = Priv; //~ WARN private type in public interface + //~^ WARNING hard error + fn deref(&self) -> &Self::Target { unimplemented!() } + } + + impl ::std::ops::Deref for Priv { + type Target = Priv; // ok + fn deref(&self) -> &Self::Target { unimplemented!() } + } +} + +trait SemiPrivTrait { + type Assoc; +} + +mod m3 { + struct Priv; + impl ::SemiPrivTrait for () { + type Assoc = Priv; //~ WARN private type in public interface + //~^ WARNING hard error + } +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful