|
| 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 | +// ignore-tidy-linelength |
| 12 | + |
| 13 | +#![feature(decl_macro, associated_type_defaults)] |
| 14 | +#![allow(unused, private_in_public)] |
| 15 | + |
| 16 | +mod priv_trait { |
| 17 | + trait PrivTr { |
| 18 | + fn method(&self) {} |
| 19 | + const CONST: u8 = 0; |
| 20 | + type AssocTy = u8; |
| 21 | + } |
| 22 | + pub struct Pub; |
| 23 | + impl PrivTr for Pub {} |
| 24 | + pub trait PubTr: PrivTr {} |
| 25 | + |
| 26 | + pub macro mac() { |
| 27 | + let value = <Pub as PrivTr>::method; |
| 28 | + //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {<priv_trait::Pub as priv_trait::PrivTr>::method}` is private |
| 29 | + value; |
| 30 | + //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {<priv_trait::Pub as priv_trait::PrivTr>::method}` is private |
| 31 | + Pub.method(); |
| 32 | + //~^ ERROR type `for<'r> fn(&'r Self) {<Self as priv_trait::PrivTr>::method}` is private |
| 33 | + <Pub as PrivTr>::CONST; |
| 34 | + //FIXME ERROR associated constant `path(PrivTr::CONST)` is private |
| 35 | + let _: <Pub as PrivTr>::AssocTy; |
| 36 | + //~^ ERROR trait `priv_trait::PrivTr` is private |
| 37 | + //~| ERROR trait `priv_trait::PrivTr` is private |
| 38 | + pub type InSignatureTy = <Pub as PrivTr>::AssocTy; |
| 39 | + //~^ ERROR trait `priv_trait::PrivTr` is private |
| 40 | + //~| ERROR trait `path(PrivTr)` is private |
| 41 | + pub trait InSignatureTr: PrivTr {} |
| 42 | + //FIXME ERROR trait `priv_trait::PrivTr` is private |
| 43 | + impl PrivTr for u8 {} |
| 44 | + //FIXME ERROR trait `priv_trait::PrivTr` is private |
| 45 | + } |
| 46 | +} |
| 47 | +fn priv_trait() { |
| 48 | + priv_trait::mac!(); |
| 49 | +} |
| 50 | + |
| 51 | +mod priv_signature { |
| 52 | + pub trait PubTr { |
| 53 | + fn method(&self, arg: Priv) {} |
| 54 | + } |
| 55 | + struct Priv; |
| 56 | + pub struct Pub; |
| 57 | + impl PubTr for Pub {} |
| 58 | + |
| 59 | + pub macro mac() { |
| 60 | + let value = <Pub as PubTr>::method; |
| 61 | + //~^ ERROR type `priv_signature::Priv` is private |
| 62 | + value; |
| 63 | + //~^ ERROR type `priv_signature::Priv` is private |
| 64 | + Pub.method(loop {}); |
| 65 | + //~^ ERROR type `priv_signature::Priv` is private |
| 66 | + } |
| 67 | +} |
| 68 | +fn priv_signature() { |
| 69 | + priv_signature::mac!(); |
| 70 | +} |
| 71 | + |
| 72 | +mod priv_substs { |
| 73 | + pub trait PubTr { |
| 74 | + fn method<T>(&self) {} |
| 75 | + } |
| 76 | + struct Priv; |
| 77 | + pub struct Pub; |
| 78 | + impl PubTr for Pub {} |
| 79 | + |
| 80 | + pub macro mac() { |
| 81 | + let value = <Pub as PubTr>::method::<Priv>; |
| 82 | + //~^ ERROR type `priv_substs::Priv` is private |
| 83 | + value; |
| 84 | + //~^ ERROR type `priv_substs::Priv` is private |
| 85 | + Pub.method::<Priv>(); |
| 86 | + //~^ ERROR type `priv_substs::Priv` is private |
| 87 | + } |
| 88 | +} |
| 89 | +fn priv_substs() { |
| 90 | + priv_substs::mac!(); |
| 91 | +} |
| 92 | + |
| 93 | +mod priv_parent_substs { |
| 94 | + pub trait PubTr<T = Priv> { |
| 95 | + fn method(&self) {} |
| 96 | + const CONST: u8 = 0; |
| 97 | + type AssocTy = u8; |
| 98 | + } |
| 99 | + struct Priv; |
| 100 | + pub struct Pub; |
| 101 | + impl PubTr<Priv> for Pub {} |
| 102 | + impl PubTr<Pub> for Priv {} |
| 103 | + |
| 104 | + pub macro mac() { |
| 105 | + let value = <Pub as PubTr>::method; |
| 106 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 107 | + value; |
| 108 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 109 | + let value = <Pub as PubTr<_>>::method; |
| 110 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 111 | + value; |
| 112 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 113 | + Pub.method(); |
| 114 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 115 | + |
| 116 | + let value = <Priv as PubTr<_>>::method; |
| 117 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 118 | + value; |
| 119 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 120 | + Priv.method(); |
| 121 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 122 | + |
| 123 | + <Pub as PubTr>::CONST; |
| 124 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 125 | + <Pub as PubTr<_>>::CONST; |
| 126 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 127 | + <Priv as PubTr<_>>::CONST; |
| 128 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 129 | + |
| 130 | + let _: <Pub as PubTr>::AssocTy; |
| 131 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 132 | + //~| ERROR type `priv_parent_substs::Priv` is private |
| 133 | + let _: <Pub as PubTr<_>>::AssocTy; |
| 134 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 135 | + //~| ERROR type `priv_parent_substs::Priv` is private |
| 136 | + let _: <Priv as PubTr<_>>::AssocTy; |
| 137 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 138 | + //~| ERROR type `priv_parent_substs::Priv` is private |
| 139 | + |
| 140 | + pub type InSignatureTy1 = <Pub as PubTr>::AssocTy; |
| 141 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 142 | + pub type InSignatureTy2 = <Priv as PubTr<Pub>>::AssocTy; |
| 143 | + //~^ ERROR type `priv_parent_substs::Priv` is private |
| 144 | + impl PubTr for u8 {} |
| 145 | + //FIXME ERROR type `priv_parent_substs::Priv` is private |
| 146 | + } |
| 147 | +} |
| 148 | +fn priv_parent_substs() { |
| 149 | + priv_parent_substs::mac!(); |
| 150 | +} |
| 151 | + |
| 152 | +fn main() {} |
0 commit comments