Uh oh!
There was an error while loading. Please reload this page.
privacy: Substitute type aliases in private-in-public checker - #34193
Conversation
There was a problem hiding this comment.
I'm having trouble seeing why this is an error.
There was a problem hiding this comment.
Priv2 is used in a public interface through an alias.
The error location here is suboptimal. On one hand Priv2 is the true source of the error and pointing to PrivAlias is misleading, on the other hand pointing to Priv2 is confusing too, because the public interface it's used in is not pointed to.
Ideally, there should be two diagnostic messages - one for the public interface location and the other for actual private type location. I'll implement this if positive decision about the whole PR is made.
There was a problem hiding this comment.
I'm confused a bit. This seems like it's causing a new error?
There was a problem hiding this comment.
This seems like it's causing a new error?
No, the error from line 211 (alias location) migrated to this line (aliased type location).
There was a problem hiding this comment.
Ideally, there should be two diagnostic messages - one for the public interface location and the other for actual private type location.
I implemented the extra note for the private type location for type aliases, but dropped it, the situation should be rare, likely happens in advanced code and doesn't worth the extra code.
Now the error is reported at the public interface location only.
There was a problem hiding this comment.
can we add a test to show that no error results?
There was a problem hiding this comment.
It's tested, the check is just moved from this file to private-in-public-warn.rs
nikomatsakis
commented
Jun 27, 2016
Ideally, we would fix rustdoc to not use private type aliases as part of this PR. |
I'll try to fix this and the error locations tomorrow. If I won't be able to, it'll have to wait for another week or so. (I also don't think these are blockers for merging the PR) |
petrochenkov
commented
Jul 3, 2016
Curiously, |
nikomatsakis
commented
Jul 7, 2016
@petrochenkov I guess it's debatable what's the right thing to do there. I mean, the link still goes to the right place, I guess, and it's not clear that showing the full path will help readability overall. (And the full path in that crate may not be the same as the full path from another crate.) In any case, it feels different, because |
petrochenkov
commented
Jul 8, 2016
Updated with rustdoc changes and tweaked error locations. |
bors
commented
Jul 15, 2016
☔ The latest upstream changes (presumably #34570) made this pull request unmergeable. Please resolve the merge conflicts. |
petrochenkov
commented
Jul 15, 2016
Rebased. |
There was a problem hiding this comment.
will this logic work if you have a private type alias that refers to another private type alias?
e.g., type A = u32; type B = A; fn foo(x: B) { }?
(Can you also add some tests for that scenario? I could imagine that even if your patch gets it right, it's something future patches might easily break.)
nikomatsakis
commented
Aug 10, 2016
r=me once new tests are added for recursive scenario |
petrochenkov
commented
Aug 10, 2016
Updated with a test for recursive substitution. |
nikomatsakis
commented
Aug 11, 2016
@bors r+ |
bors
commented
Aug 11, 2016
📌 Commit 5d4ae4b has been approved by |
bors
commented
Aug 11, 2016
⌛ Testing commit 5d4ae4b with merge 11f8805... |
privacy: Substitute type aliases in private-in-public checker Closes#30503Closes#34293 Everyone in the issue discussion seemed to be in favor, @huonw also spoke about this [here](https://www.reddit.com/r/rust/comments/3xldr9/surfaces_and_signatures_component_privacy_versus/cy615wq), but the issue haven't got any movement. I think it's reasonable to do this before turning `private_in_public` warnings into errors. r? @nikomatsakis
Closes#30503
Closes#34293
Everyone in the issue discussion seemed to be in favor, @huonw also spoke about this here, but the issue haven't got any movement.
I think it's reasonable to do this before turning
private_in_publicwarnings into errors.r? @nikomatsakis