-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long compile time due to privacy checking private alias of public type #50614
Comments
Track down: rust/src/librustc_privacy/lib.rs Lines 1471 to 1490 in acd3871
Git blame: @eddyb |
Does this only happen with errors, or can compilation succeed? |
From my understanding, what the comment says is false and it seems private items are unconditionally pushed onto the list. The program compiles successfully. |
This comment has been minimized.
This comment has been minimized.
I'm reviewing Private alias of public type:
Public alias of public type
|
Precompute ancestors when checking privacy Precompute ancestors of the old error node set so that check for private types and traits in public interfaces can in constant time determine if the current item has any descendants in the old error set. This removes disparity in compilation time between public and private type aliases reported in rust-lang#50614 (from 30 s to 5 s, in an example making extensive use of private type aliases). No functional changes intended.
By coincidence I just happened to already have nightly-2021-02-19 installed which was the first version including @tmiasko's fix.
A non-scientific 10,000 % speed up with |
Actually closing the issue now! I verified one more time that compile times are consistent with the public and private type aliases. Pub:
Priv:
|
Private type aliases of public types (e.g.
type V = f32;
) cause long compile times in the privacy checking phase. Making the type alias public resolves the issue. See iliekturtles/uom#52 where the issue was originally identified and the work-around was found. See privacy_checking.rs for a simple example to reproduce the problem.The following command can be used to reproduce the problem with a private type alias.
Replacing the
priv
feature withpub
shows that the issue is corrected when using a public type alias.Varying the
T_
(number of types) andI_
(number of traitimpl
s) features shows how compile times change. See the below test data from my machine. It looks like privacy checking of a private type alias of a public type is exponential with the number of types and becomes linear with a very slight slope when checking public aliases.The text was updated successfully, but these errors were encountered: