From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/privacy/associated-item-privacy-trait.rs | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tests/ui/privacy/associated-item-privacy-trait.rs (limited to 'tests/ui/privacy/associated-item-privacy-trait.rs') diff --git a/tests/ui/privacy/associated-item-privacy-trait.rs b/tests/ui/privacy/associated-item-privacy-trait.rs new file mode 100644 index 000000000..c686a2177 --- /dev/null +++ b/tests/ui/privacy/associated-item-privacy-trait.rs @@ -0,0 +1,134 @@ +#![feature(decl_macro, associated_type_defaults)] +#![allow(unused, private_in_public)] + +mod priv_trait { + trait PrivTr { + fn method(&self) {} + const CONST: u8 = 0; + type AssocTy = u8; + } + pub struct Pub; + impl PrivTr for Pub {} + pub trait PubTr: PrivTr {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + value; + //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + Pub.method(); + //~^ ERROR type `for<'a> fn(&'a Self) {::method}` is private + ::CONST; + //~^ ERROR associated constant `PrivTr::CONST` is private + let _: ::AssocTy; + //~^ ERROR associated type `PrivTr::AssocTy` is private + pub type InSignatureTy = ::AssocTy; + //~^ ERROR trait `PrivTr` is private + pub trait InSignatureTr: PrivTr {} + //~^ ERROR trait `PrivTr` is private + impl PrivTr for u8 {} + //~^ ERROR trait `PrivTr` is private + } +} +fn priv_trait() { + priv_trait::mac!(); +} + +mod priv_signature { + pub trait PubTr { + fn method(&self, arg: Priv) {} + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `priv_signature::Priv` is private + value; + //~^ ERROR type `priv_signature::Priv` is private + Pub.method(loop {}); + //~^ ERROR type `priv_signature::Priv` is private + } +} +fn priv_signature() { + priv_signature::mac!(); +} + +mod priv_substs { + pub trait PubTr { + fn method(&self) {} + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + + pub macro mac() { + let value = ::method::; + //~^ ERROR type `priv_substs::Priv` is private + value; + //~^ ERROR type `priv_substs::Priv` is private + Pub.method::(); + //~^ ERROR type `priv_substs::Priv` is private + } +} +fn priv_substs() { + priv_substs::mac!(); +} + +mod priv_parent_substs { + pub trait PubTr { + fn method(&self) {} + const CONST: u8 = 0; + type AssocTy = u8; + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + impl PubTr for Priv {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + let value = >::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + Pub.method(); + //~^ ERROR type `priv_parent_substs::Priv` is private + + let value = >::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + Priv.method(); + //~^ ERROR type `priv_parent_substs::Priv` is private + + ::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + >::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + >::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + + let _: ::AssocTy; // FIXME no longer an error?! + let _: >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + let _: >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + + pub type InSignatureTy1 = ::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + pub type InSignatureTy2 = >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + impl PubTr for u8 {} + //~^ ERROR type `priv_parent_substs::Priv` is private + } +} +fn priv_parent_substs() { + priv_parent_substs::mac!(); +} + +fn main() {} -- cgit v1.2.3