Description
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.
time rustc +nightly --crate-type lib privacy_checking.rs -Ztime-passes --cfg 'feature="priv"' --cfg 'feature="T6"' --cfg 'feature="I5"'
Replacing the priv
feature with pub
shows that the issue is corrected when using a public type alias.
time rustc +nightly --crate-type lib privacy_checking.rs -Ztime-passes --cfg 'feature="pub"' --cfg 'feature="T6"' --cfg 'feature="I5"'
Varying the T_
(number of types) and I_
(number of trait impl
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.
Types | Impls | Ty x Impl | Time | Privacy checking | Time (pub) | Privacy checking (pub) |
---|---|---|---|---|---|---|
1 | 5 | 5 | 1.324 | 0.206 | 1.123 | 0.023 |
2 | 5 | 10 | 2.816 | 0.823 | 1.999 | 0.061 |
3 | 5 | 15 | 4.641 | 1.853 | 2.827 | 0.080 |
4 | 5 | 20 | 6.968 | 3.243 | 3.714 | 0.103 |
5 | 5 | 25 | 9.219 | 4.700 | 4.686 | 0.129 |
6 | 5 | 30 | 12.721 | 7.371 | 5.598 | 0.163 |