- Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Closed
Copy link
Labels
A-visibilityArea: Visibility / privacyArea: Visibility / privacy
Description
Surely adding a type ascription shouldn't cause a privacy violation, right? And yet...
Example file (a.rs):
mod a { struct S; #[cfg(not(hide_impl))] impl S { } pub struct Expose; impl Expose { pub fn expose(&self) -> S { S } } } fn f_infer() { let _s; _s = a::Expose.expose(); } #[cfg(demo_explicit)] fn f_typed() { let _s : a::S; _s = a::Expose.expose(); } fn main() {}Some runs illustrating the bug. Note that the only difference introduced by hide_impl is whether or not the empty impl item for S is present, and therefore toggling it should not (IMO) be causing changes to the privacy semantics.
% rustc a.rs % rustc --cfg demo_explicit a.rs % rustc --cfg hide_impl a.rs % rustc --cfg hide_impl --cfg demo_explicit a.rs a.rs:18:13: 18:17 error: type `S` is private a.rs:18 let _s : a::S; ^~~~ error: aborting due to previous error task 'rustc' failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/libsyntax/diagnostic.rs:101 task '<main>' failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/lib.rs:396 (Possibly related to #10545, but do note that the properties of these two scenarios do differ. In particular, the presence/absence of fields in the struct seems to be irrelevant for this bug.)
Metadata
Metadata
Assignees
Labels
A-visibilityArea: Visibility / privacyArea: Visibility / privacy