summaryrefslogtreecommitdiffstats
path: root/src/test/ui/privacy/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/privacy/auxiliary')
-rw-r--r--src/test/ui/privacy/auxiliary/cci_class.rs14
-rw-r--r--src/test/ui/privacy/auxiliary/cci_class_5.rs17
-rw-r--r--src/test/ui/privacy/auxiliary/ctor_aux.rs25
-rw-r--r--src/test/ui/privacy/auxiliary/impl_privacy_xc_2.rs13
-rw-r--r--src/test/ui/privacy/auxiliary/issue-57264-1.rs9
-rw-r--r--src/test/ui/privacy/auxiliary/issue-57264-2.rs10
-rw-r--r--src/test/ui/privacy/auxiliary/issue-92755.rs17
-rw-r--r--src/test/ui/privacy/auxiliary/priv-impl-prim-ty.rs9
-rw-r--r--src/test/ui/privacy/auxiliary/privacy_reexport.rs6
-rw-r--r--src/test/ui/privacy/auxiliary/privacy_tuple_struct.rs4
-rw-r--r--src/test/ui/privacy/auxiliary/private-inferred-type.rs36
-rw-r--r--src/test/ui/privacy/auxiliary/pub_use_mods_xcrate.rs10
-rw-r--r--src/test/ui/privacy/auxiliary/pub_use_xcrate1.rs3
-rw-r--r--src/test/ui/privacy/auxiliary/pub_use_xcrate2.rs3
-rw-r--r--src/test/ui/privacy/auxiliary/reachable-unnameable-items.rs106
15 files changed, 282 insertions, 0 deletions
diff --git a/src/test/ui/privacy/auxiliary/cci_class.rs b/src/test/ui/privacy/auxiliary/cci_class.rs
new file mode 100644
index 000000000..de2945d74
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/cci_class.rs
@@ -0,0 +1,14 @@
+pub mod kitties {
+ pub struct cat {
+ meows : usize,
+
+ pub how_hungry : isize,
+ }
+
+ pub fn cat(in_x : usize, in_y : isize) -> cat {
+ cat {
+ meows: in_x,
+ how_hungry: in_y
+ }
+ }
+}
diff --git a/src/test/ui/privacy/auxiliary/cci_class_5.rs b/src/test/ui/privacy/auxiliary/cci_class_5.rs
new file mode 100644
index 000000000..3aeaa83d3
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/cci_class_5.rs
@@ -0,0 +1,17 @@
+pub mod kitties {
+ pub struct cat {
+ meows : usize,
+ pub how_hungry : isize,
+ }
+
+ impl cat {
+ fn nap(&self) {}
+ }
+
+ pub fn cat(in_x : usize, in_y : isize) -> cat {
+ cat {
+ meows: in_x,
+ how_hungry: in_y
+ }
+ }
+}
diff --git a/src/test/ui/privacy/auxiliary/ctor_aux.rs b/src/test/ui/privacy/auxiliary/ctor_aux.rs
new file mode 100644
index 000000000..9c99cca9a
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/ctor_aux.rs
@@ -0,0 +1,25 @@
+// edition:2021
+//! Missing docs lint warns about undocumented exported items.
+//! Use the lint to additionally verify that items are reachable
+//! but not exported.
+#![allow(non_camel_case_types)]
+#![deny(missing_docs)]
+
+mod hidden {
+ pub struct s;
+ pub enum e { x, y, z }
+ pub use e::*;
+ impl s {
+ pub fn f(&self) {}
+ }
+ impl e {
+ pub fn g(&self) {}
+ }
+}
+// Hide all type definitions while reexporting their constructors:
+mod e {}
+mod x {}
+mod y {}
+mod z {}
+mod s {}
+pub use hidden::*;
diff --git a/src/test/ui/privacy/auxiliary/impl_privacy_xc_2.rs b/src/test/ui/privacy/auxiliary/impl_privacy_xc_2.rs
new file mode 100644
index 000000000..5f9c22681
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/impl_privacy_xc_2.rs
@@ -0,0 +1,13 @@
+#![crate_type = "lib"]
+
+pub struct Fish {
+ pub x: isize
+}
+
+mod unexported {
+ use super::Fish;
+ impl PartialEq for Fish {
+ fn eq(&self, _: &Fish) -> bool { true }
+ fn ne(&self, _: &Fish) -> bool { false }
+ }
+}
diff --git a/src/test/ui/privacy/auxiliary/issue-57264-1.rs b/src/test/ui/privacy/auxiliary/issue-57264-1.rs
new file mode 100644
index 000000000..9302fa0d9
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/issue-57264-1.rs
@@ -0,0 +1,9 @@
+mod inner {
+ pub struct PubUnnameable;
+}
+
+pub struct Pub<T>(T);
+
+impl Pub<inner::PubUnnameable> {
+ pub fn pub_method() {}
+}
diff --git a/src/test/ui/privacy/auxiliary/issue-57264-2.rs b/src/test/ui/privacy/auxiliary/issue-57264-2.rs
new file mode 100644
index 000000000..416206b4f
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/issue-57264-2.rs
@@ -0,0 +1,10 @@
+mod inner {
+ pub struct PubUnnameable;
+
+ impl PubUnnameable {
+ pub fn pub_method(self) {}
+ }
+}
+
+pub trait PubTraitWithSingleImplementor {}
+impl PubTraitWithSingleImplementor for Option<inner::PubUnnameable> {}
diff --git a/src/test/ui/privacy/auxiliary/issue-92755.rs b/src/test/ui/privacy/auxiliary/issue-92755.rs
new file mode 100644
index 000000000..6f8527346
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/issue-92755.rs
@@ -0,0 +1,17 @@
+mod machine {
+ pub struct A {
+ pub b: B,
+ }
+ pub struct B {}
+ impl B {
+ pub fn f(&self) {}
+ }
+}
+
+pub struct Context {
+ pub a: machine::A,
+}
+
+pub fn ctx() -> Context {
+ todo!();
+}
diff --git a/src/test/ui/privacy/auxiliary/priv-impl-prim-ty.rs b/src/test/ui/privacy/auxiliary/priv-impl-prim-ty.rs
new file mode 100644
index 000000000..8ccbd3f12
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/priv-impl-prim-ty.rs
@@ -0,0 +1,9 @@
+pub trait A {
+ fn frob(&self);
+}
+
+impl A for isize { fn frob(&self) {} }
+
+pub fn frob<T:A>(t: T) {
+ t.frob();
+}
diff --git a/src/test/ui/privacy/auxiliary/privacy_reexport.rs b/src/test/ui/privacy/auxiliary/privacy_reexport.rs
new file mode 100644
index 000000000..6b72dbc92
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/privacy_reexport.rs
@@ -0,0 +1,6 @@
+pub extern crate core;
+pub use foo as bar;
+
+pub mod foo {
+ pub fn frob() {}
+}
diff --git a/src/test/ui/privacy/auxiliary/privacy_tuple_struct.rs b/src/test/ui/privacy/auxiliary/privacy_tuple_struct.rs
new file mode 100644
index 000000000..223cda4b2
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/privacy_tuple_struct.rs
@@ -0,0 +1,4 @@
+pub struct A(());
+pub struct B(isize);
+pub struct C(pub isize, isize);
+pub struct D(pub isize);
diff --git a/src/test/ui/privacy/auxiliary/private-inferred-type.rs b/src/test/ui/privacy/auxiliary/private-inferred-type.rs
new file mode 100644
index 000000000..7ac913f5b
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/private-inferred-type.rs
@@ -0,0 +1,36 @@
+#![feature(decl_macro)]
+
+fn priv_fn() {}
+static PRIV_STATIC: u8 = 0;
+enum PrivEnum { Variant }
+pub enum PubEnum { Variant }
+trait PrivTrait { fn method() {} }
+impl PrivTrait for u8 {}
+pub trait PubTrait { fn method() {} }
+impl PubTrait for u8 {}
+struct PrivTupleStruct(u8);
+pub struct PubTupleStruct(u8);
+impl PubTupleStruct { fn method() {} }
+
+struct Priv;
+pub type Alias = Priv;
+pub struct Pub<T = Alias>(pub T);
+
+impl Pub<Priv> {
+ pub fn static_method() {}
+}
+impl Pub<u8> {
+ fn priv_method(&self) {}
+}
+
+pub macro m() {
+ priv_fn;
+ PRIV_STATIC;
+ PrivEnum::Variant;
+ PubEnum::Variant;
+ <u8 as PrivTrait>::method;
+ <u8 as PubTrait>::method;
+ PrivTupleStruct;
+ PubTupleStruct;
+ Pub(0u8).priv_method();
+}
diff --git a/src/test/ui/privacy/auxiliary/pub_use_mods_xcrate.rs b/src/test/ui/privacy/auxiliary/pub_use_mods_xcrate.rs
new file mode 100644
index 000000000..74d3504d5
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/pub_use_mods_xcrate.rs
@@ -0,0 +1,10 @@
+pub mod a {
+ pub use a::b::c;
+
+ pub mod b {
+ pub mod c {
+ fn f(){}
+ fn g(){}
+ }
+ }
+}
diff --git a/src/test/ui/privacy/auxiliary/pub_use_xcrate1.rs b/src/test/ui/privacy/auxiliary/pub_use_xcrate1.rs
new file mode 100644
index 000000000..772c9627a
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/pub_use_xcrate1.rs
@@ -0,0 +1,3 @@
+pub struct Foo {
+ pub name: isize
+}
diff --git a/src/test/ui/privacy/auxiliary/pub_use_xcrate2.rs b/src/test/ui/privacy/auxiliary/pub_use_xcrate2.rs
new file mode 100644
index 000000000..20d7066d3
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/pub_use_xcrate2.rs
@@ -0,0 +1,3 @@
+extern crate pub_use_xcrate1;
+
+pub use pub_use_xcrate1::Foo;
diff --git a/src/test/ui/privacy/auxiliary/reachable-unnameable-items.rs b/src/test/ui/privacy/auxiliary/reachable-unnameable-items.rs
new file mode 100644
index 000000000..20f110b1a
--- /dev/null
+++ b/src/test/ui/privacy/auxiliary/reachable-unnameable-items.rs
@@ -0,0 +1,106 @@
+use inner_private_module::*;
+
+mod inner_private_module {
+ pub struct Unnameable1;
+ pub struct Unnameable2;
+ #[derive(Clone, Copy)]
+ pub struct Unnameable3;
+ pub struct Unnameable4;
+ pub struct Unnameable5;
+ pub struct Unnameable6;
+ pub struct Unnameable7;
+ #[derive(Default)]
+ pub struct Unnameable8;
+ pub enum UnnameableEnum {
+ NameableVariant
+ }
+ pub trait UnnameableTrait {
+ type Alias: Default;
+ }
+
+ impl Unnameable1 {
+ pub fn method_of_unnameable_type1(&self) -> &'static str {
+ "Hello1"
+ }
+ }
+ impl Unnameable2 {
+ pub fn method_of_unnameable_type2(&self) -> &'static str {
+ "Hello2"
+ }
+ }
+ impl Unnameable3 {
+ pub fn method_of_unnameable_type3(&self) -> &'static str {
+ "Hello3"
+ }
+ }
+ impl Unnameable4 {
+ pub fn method_of_unnameable_type4(&self) -> &'static str {
+ "Hello4"
+ }
+ }
+ impl Unnameable5 {
+ pub fn method_of_unnameable_type5(&self) -> &'static str {
+ "Hello5"
+ }
+ }
+ impl Unnameable6 {
+ pub fn method_of_unnameable_type6(&self) -> &'static str {
+ "Hello6"
+ }
+ }
+ impl Unnameable7 {
+ pub fn method_of_unnameable_type7(&self) -> &'static str {
+ "Hello7"
+ }
+ }
+ impl Unnameable8 {
+ pub fn method_of_unnameable_type8(&self) -> &'static str {
+ "Hello8"
+ }
+ }
+ impl UnnameableEnum {
+ pub fn method_of_unnameable_enum(&self) -> &'static str {
+ "HelloEnum"
+ }
+ }
+}
+
+pub fn function_returning_unnameable_type() -> Unnameable1 {
+ Unnameable1
+}
+
+pub const CONSTANT_OF_UNNAMEABLE_TYPE: Unnameable2 =
+ Unnameable2;
+
+pub fn function_accepting_unnameable_type(_: Option<Unnameable3>) {}
+
+pub type AliasOfUnnameableType = Unnameable4;
+
+impl Unnameable1 {
+ pub fn inherent_method_returning_unnameable_type(&self) -> Unnameable5 {
+ Unnameable5
+ }
+}
+
+pub trait Tr {
+ fn trait_method_returning_unnameable_type(&self) -> Unnameable6 {
+ Unnameable6
+ }
+}
+impl Tr for Unnameable1 {}
+
+pub use inner_private_module::UnnameableEnum::NameableVariant;
+
+pub struct Struct {
+ pub field_of_unnameable_type: Unnameable7
+}
+
+pub static STATIC: Struct = Struct { field_of_unnameable_type: Unnameable7 } ;
+
+impl UnnameableTrait for AliasOfUnnameableType {
+ type Alias = Unnameable8;
+}
+
+pub fn generic_function<T: UnnameableTrait>() -> T::Alias {
+ Default::default()
+}