Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider substituting type aliases in "public-in-private" checker #30503
Comments
This comment has been minimized.
This comment has been minimized.
|
Just to give a concrete example, the current behavior even disallows type aliases in locations which are effectively private. An example from diesel is https://github.com/sgrif/diesel/blob/c8127d408f759faa056503014cd00e92479215e0/diesel/src/query_builder/select_statement/dsl_impls.rs#L54-L67, where the type alias is purely used for brevity in what is effectively an internal impl of a trait, but is disallowed because the trait itself is public. |
This comment has been minimized.
This comment has been minimized.
The logic is that both the trait and the type are public, so the impl is public as well. (But this is a digression) |
This comment has been minimized.
This comment has been minimized.
|
Right, I fully understand the logic. My argument is that it's an ergonomics On Sun, Dec 20, 2015, 6:04 PM Vadim Petrochenkov notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
cc @seanmonstar |
This comment has been minimized.
This comment has been minimized.
|
Yes! |
This comment has been minimized.
This comment has been minimized.
|
I'm basically in favor of this; I have some vague concerns about specifying it literally as substitution of the right hand side given that we have parameters to consider in the general case, but it seems plausible that kind of substitution works out fine. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @retep998 |
This comment has been minimized.
This comment has been minimized.
|
I pretty much make everything pub anyway so this doesn't really affect winapi either way. The thing that did affect winapi was things like |
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Feb 8, 2016
|
I'd be in favor of something like type Foo = usize; // This is a type alias which must always be preserved.
alias Bar = usize; // This is a type alias which always gets substituted when crossing modules.This allows alias Return = (usize, isize);
mod a {
fn foo() -> super::Return;
}
mod b {
fn foo() -> super::Return;
}But is documented as returning a |
nixpulvis
referenced this issue
Feb 9, 2016
Open
Trait bounds are not yet enforced in type definitions #21903
petrochenkov
referenced this issue
Mar 17, 2016
Closed
Possibly bogus private type warning with trait impls #32318
petrochenkov
referenced this issue
Jun 9, 2016
Merged
privacy: Substitute type aliases in private-in-public checker #34193
This comment has been minimized.
This comment has been minimized.
|
I think the primary concern with this was rustdoc -- which will show these private aliases -- but we could probably change rustdoc's behavior to expand private aliases. |
petrochenkov
referenced this issue
Jun 16, 2016
Closed
Rust complains about "private type in public interface" even though the type and interface are both aliases. #34293
nikomatsakis
added
I-nominated
T-lang
labels
Jun 27, 2016
This comment has been minimized.
This comment has been minimized.
|
I'm nominating this issue -- I agree with @petrochenkov that it makes sense to make this change before making the warnings into hard errors -- I am a bit unclear on whether we think an RFC would be required or what. |
This comment has been minimized.
This comment has been minimized.
|
Also as it happens @wycats was just complaining to me today that private type aliases cause these issues. :) |
aturon
removed
the
I-nominated
label
Jul 7, 2016
This comment has been minimized.
This comment has been minimized.
|
Just opened rust-lang/rfcs#1671 which includes this feature. |
nikomatsakis
added
the
I-nominated
label
Jul 21, 2016
nikomatsakis
removed
the
I-nominated
label
Aug 4, 2016
This comment has been minimized.
This comment has been minimized.
|
So @nrc and I discussed this -- but we're the only ones in the @rust-lang/lang meeting due to various reasons -- we both feel like we should accept this change (use the semantic type, not the type alias) and probably also adopt the simpler version of @eddyb's proposal that is described on internals. |
petrochenkov commentedDec 21, 2015
E.g. allowing things like
This was originally done in #29973, but reverted later to follow the letter of RFC 136.
Now it starts hitting people. I think this should be reconsidered sooner than later to reduce the number of annoyed people.
Type alias substitution reduces the breakage by 25% according to the crater data.