]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/private-type-in-interface.rs
a5581664f741859baa603fd7c7b140a73f850d60
[rust.git] / src / test / compile-fail / private-type-in-interface.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // aux-build:private-inferred-type.rs
12
13 #![feature(conservative_impl_trait)]
14 #![allow(warnings)]
15
16 extern crate private_inferred_type as ext;
17
18 mod m {
19     struct Priv;
20     pub type Alias = Priv;
21
22     pub trait Trait { type X; }
23     impl Trait for Priv { type X = u8; }
24 }
25
26 fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private
27                      //~^ ERROR type `m::Priv` is private
28 fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private
29                            //~^ ERROR type `ext::Priv` is private
30
31 trait Tr1 {}
32 impl m::Alias {} //~ ERROR type `m::Priv` is private
33 impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private
34                            //~^ ERROR type `ext::Priv` is private
35 type A = <m::Alias as m::Trait>::X; //~ ERROR type `m::Priv` is private
36
37 trait Tr2<T> {}
38 impl<T> Tr2<T> for u8 {}
39 fn g() -> impl Tr2<m::Alias> { 0 } //~ ERROR type `m::Priv` is private
40 fn g_ext() -> impl Tr2<ext::Alias> { 0 } //~ ERROR type `ext::Priv` is private
41
42 fn main() {}