]> git.lizzy.rs Git - rust.git/blob - src/test/ui/privacy/associated-item-privacy-type-binding.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / privacy / associated-item-privacy-type-binding.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 #![feature(decl_macro, associated_type_defaults)]
12 #![allow(unused, private_in_public)]
13
14 mod priv_trait {
15     trait PrivTr {
16         type AssocTy = u8;
17     }
18     pub trait PubTr: PrivTr {}
19
20     pub macro mac1() {
21         let _: Box<PubTr<AssocTy = u8>>;
22         //~^ ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
23         //~| ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + '<empty>)` is private
24         type InSignatureTy2 = Box<PubTr<AssocTy = u8>>;
25         //~^ ERROR type `(dyn priv_trait::PubTr<AssocTy=u8> + 'static)` is private
26         trait InSignatureTr2: PubTr<AssocTy = u8> {}
27         //~^ ERROR trait `priv_trait::PrivTr` is private
28     }
29     pub macro mac2() {
30         let _: Box<PrivTr<AssocTy = u8>>;
31         //~^ ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
32         //~| ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + '<empty>)` is private
33         type InSignatureTy1 = Box<PrivTr<AssocTy = u8>>;
34         //~^ ERROR type `(dyn priv_trait::PrivTr<AssocTy=u8> + 'static)` is private
35         trait InSignatureTr1: PrivTr<AssocTy = u8> {}
36         //~^ ERROR trait `priv_trait::PrivTr` is private
37     }
38 }
39 fn priv_trait1() {
40     priv_trait::mac1!();
41 }
42 fn priv_trait2() {
43     priv_trait::mac2!();
44 }
45
46 mod priv_parent_substs {
47     pub trait PubTrWithParam<T = Priv> {
48         type AssocTy = u8;
49     }
50     struct Priv;
51     pub trait PubTr: PubTrWithParam<Priv> {}
52
53     pub macro mac() {
54         let _: Box<PubTrWithParam<AssocTy = u8>>;
55         //~^ ERROR type `priv_parent_substs::Priv` is private
56         //~| ERROR type `priv_parent_substs::Priv` is private
57         let _: Box<PubTr<AssocTy = u8>>;
58         //~^ ERROR type `priv_parent_substs::Priv` is private
59         //~| ERROR type `priv_parent_substs::Priv` is private
60         pub type InSignatureTy1 = Box<PubTrWithParam<AssocTy = u8>>;
61         //~^ ERROR type `priv_parent_substs::Priv` is private
62         pub type InSignatureTy2 = Box<PubTr<AssocTy = u8>>;
63         //~^ ERROR type `priv_parent_substs::Priv` is private
64         trait InSignatureTr1: PubTrWithParam<AssocTy = u8> {}
65         //~^ ERROR type `priv_parent_substs::Priv` is private
66         trait InSignatureTr2: PubTr<AssocTy = u8> {}
67         //~^ ERROR type `priv_parent_substs::Priv` is private
68     }
69 }
70 fn priv_parent_substs() {
71     priv_parent_substs::mac!();
72 }
73
74 fn main() {}