resolve: More detailed effective visibility tracking for imports
Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.
This commit is contained in:
parent
452cf4f710
commit
24093fc6bd
7 changed files with 213 additions and 107 deletions
|
|
@ -6,7 +6,7 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub
|
|||
pub mod inner1 { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
|
||||
#[rustc_effective_visibility]
|
||||
extern "C" {} //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
extern "C" {} //~ ERROR not in the table
|
||||
|
||||
#[rustc_effective_visibility]
|
||||
pub trait PubTrait { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImpl
|
|||
LL | pub mod inner1 {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
error: not in the table
|
||||
--> $DIR/effective_visibilities.rs:9:9
|
||||
|
|
||||
LL | extern "C" {}
|
||||
|
|
|
|||
21
src/test/ui/privacy/effective_visibilities_glob.rs
Normal file
21
src/test/ui/privacy/effective_visibilities_glob.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Effective visibility tracking for imports is fine-grained, so `S2` is not fully exported
|
||||
// even if its parent import (`m::*`) is fully exported as a `use` item.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
mod m {
|
||||
#[rustc_effective_visibility]
|
||||
pub struct S1 {} //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
#[rustc_effective_visibility]
|
||||
pub struct S2 {} //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate)
|
||||
}
|
||||
|
||||
mod glob {
|
||||
#[rustc_effective_visibility]
|
||||
pub use crate::m::*; //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
}
|
||||
|
||||
#[rustc_effective_visibility]
|
||||
pub use glob::S1; //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/privacy/effective_visibilities_glob.stderr
Normal file
26
src/test/ui/privacy/effective_visibilities_glob.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
--> $DIR/effective_visibilities_glob.rs:8:5
|
||||
|
|
||||
LL | pub struct S1 {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate)
|
||||
--> $DIR/effective_visibilities_glob.rs:10:5
|
||||
|
|
||||
LL | pub struct S2 {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
--> $DIR/effective_visibilities_glob.rs:15:13
|
||||
|
|
||||
LL | pub use crate::m::*;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub
|
||||
--> $DIR/effective_visibilities_glob.rs:19:9
|
||||
|
|
||||
LL | pub use glob::S1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue