about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-21 20:23:26 +0000
committerbors <bors@rust-lang.org>2020-10-21 20:23:26 +0000
commit1eaadebb3dee31669c7649b32747381d11614fae (patch)
treebae167a7740a9ca9f397f56b025bae5ea9c82655 /src/test/ui/error-codes
parent1d2726726f8f3128e98191e4c6cb94bd76d0ddd4 (diff)
parentcee5521a03e81e75516a90c1a616c97545d8e07a (diff)
downloadrust-1eaadebb3dee31669c7649b32747381d11614fae.tar.gz
rust-1eaadebb3dee31669c7649b32747381d11614fae.zip
Auto merge of #78077 - petrochenkov:qvis, r=davidtwco
Calculate visibilities once in resolve

Then use them through a query based on resolver outputs.

Item visibilities were previously calculated in three places - initially in `rustc_resolve`, then in `rustc_privacy` during type privacy checkin, and then in `rustc_metadata` during metadata encoding.
The visibility logic is not entirely trivial, especially for things like constructors or enum variants, and all of it was duplicated.

This PR deduplicates all the visibility calculations, visibilities are determined once during early name resolution and then stored in `ResolverOutputs` and are later available through `tcx` as a query `tcx.visibility(def_id)`.
(This query existed previously, but only worked for other crates.)

Some special cases (e.g. visibilities for closure types, which are needed for type privacy checking) are not processed in resolve, but deferred and performed directly in the query instead.
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0445.stderr9
-rw-r--r--src/test/ui/error-codes/E0446.stderr2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/test/ui/error-codes/E0445.stderr b/src/test/ui/error-codes/E0445.stderr
index 953a626bf95..1a66e0a2f97 100644
--- a/src/test/ui/error-codes/E0445.stderr
+++ b/src/test/ui/error-codes/E0445.stderr
@@ -1,18 +1,27 @@
 error[E0445]: private trait `Foo` in public interface
   --> $DIR/E0445.rs:5:1
    |
+LL | trait Foo {
+   | --------- `Foo` declared as private
+...
 LL | pub trait Bar : Foo {}
    | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `Foo` in public interface
   --> $DIR/E0445.rs:7:1
    |
+LL | trait Foo {
+   | --------- `Foo` declared as private
+...
 LL | pub struct Bar2<T: Foo>(pub T);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `Foo` in public interface
   --> $DIR/E0445.rs:9:1
    |
+LL | trait Foo {
+   | --------- `Foo` declared as private
+...
 LL | pub fn foo<T: Foo> (t: T) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
diff --git a/src/test/ui/error-codes/E0446.stderr b/src/test/ui/error-codes/E0446.stderr
index c538bae2e5e..73b6ba3c50e 100644
--- a/src/test/ui/error-codes/E0446.stderr
+++ b/src/test/ui/error-codes/E0446.stderr
@@ -2,7 +2,7 @@ error[E0446]: private type `Bar` in public interface
   --> $DIR/E0446.rs:4:5
    |
 LL |     struct Bar(u32);
-   |     - `Bar` declared as private
+   |     ---------------- `Bar` declared as private
 LL | 
 LL |     pub fn bar() -> Bar {
    |     ^^^^^^^^^^^^^^^^^^^ can't leak private type