about summary refs log tree commit diff
path: root/tests/ui/const-generics/generic_const_exprs
diff options
context:
space:
mode:
authorBryanskiy <ivakin.kir@gmail.com>2023-05-18 14:57:45 +0300
committerBryanskiy <ivakin.kir@gmail.com>2023-06-12 01:02:19 +0300
commit6d46382f6f0688df0fc5c67386f86ccd6fdb975f (patch)
treeda222fe6ab404e953e1683070bdd60a700b5991c /tests/ui/const-generics/generic_const_exprs
parentd0ee1908ed791d3e91d2ad74ba502eaa203cff6d (diff)
downloadrust-6d46382f6f0688df0fc5c67386f86ccd6fdb975f.tar.gz
rust-6d46382f6f0688df0fc5c67386f86ccd6fdb975f.zip
Private-in-public lints implementation
Diffstat (limited to 'tests/ui/const-generics/generic_const_exprs')
-rw-r--r--tests/ui/const-generics/generic_const_exprs/eval-privacy.rs6
-rw-r--r--tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr22
2 files changed, 26 insertions, 2 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs
index 8023b998a40..96b769699cc 100644
--- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs
+++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs
@@ -2,6 +2,12 @@
 #![feature(generic_const_exprs)]
 #![allow(incomplete_features)]
 
+#![warn(private_interfaces)]
+
+// In this test both old and new private-in-public diagnostic were emitted.
+// Old diagnostic will be deleted soon.
+// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
+
 pub struct Const<const U: u8>;
 
 pub trait Trait {
diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr
index 2d9de8805bb..465621619b4 100644
--- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr
@@ -1,5 +1,5 @@
 error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface
-  --> $DIR/eval-privacy.rs:16:5
+  --> $DIR/eval-privacy.rs:22:5
    |
 LL |     type AssocTy = Const<{ my_const_fn(U) }>;
    |     ^^^^^^^^^^^^ can't leak private type
@@ -7,6 +7,24 @@ LL |     type AssocTy = Const<{ my_const_fn(U) }>;
 LL | const fn my_const_fn(val: u8) -> u8 {
    | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private
 
-error: aborting due to previous error
+warning: type `fn(u8) -> u8 {my_const_fn}` is more private than the item `<Const<U> as Trait>::AssocTy`
+   |
+note: associated type `<Const<U> as Trait>::AssocTy` is reachable at visibility `pub`
+  --> $DIR/eval-privacy.rs:22:5
+   |
+LL |     type AssocTy = Const<{ my_const_fn(U) }>;
+   |     ^^^^^^^^^^^^
+note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)`
+  --> $DIR/eval-privacy.rs:29:1
+   |
+LL | const fn my_const_fn(val: u8) -> u8 {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: the lint level is defined here
+  --> $DIR/eval-privacy.rs:5:9
+   |
+LL | #![warn(private_interfaces)]
+   |         ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0446`.