]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/private-type-in-interface.rs
Nest the `impl Trait` existential item inside the return type
[rust.git] / src / test / ui / privacy / 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 #![allow(warnings)]
14
15 extern crate private_inferred_type as ext;
16
17 mod m {
18     struct Priv;
19     pub type Alias = Priv;
20
21     pub trait Trait { type X; }
22     impl Trait for Priv { type X = u8; }
23 }
24
25 fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private
26                      //~^ ERROR type `m::Priv` is private
27 fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private
28                            //~^ ERROR type `ext::Priv` is private
29
30 trait Tr1 {}
31 impl m::Alias {} //~ ERROR type `m::Priv` is private
32 impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private
33 type A = <m::Alias as m::Trait>::X; //~ ERROR type `m::Priv` is private
34
35 trait Tr2<T> {}
36 impl<T> Tr2<T> for u8 {}
37 fn g() -> impl Tr2<m::Alias> { 0 } //~ ERROR type `m::Priv` is private
38 fn g_ext() -> impl Tr2<ext::Alias> { 0 } //~ ERROR type `ext::Priv` is private
39
40 fn main() {}