Skip to content

Large ZST arrays take a looong time to compile #68010

Closed
@Nemo157

Description

@Nemo157

Test case:

fn main() { println!("{}", [(); std::usize::MAX].len()); }

I left it compiling for just over half an hour, and it sat at constant memory usage and 100% of a CPU core for the entire time. Originally tested on rustc 1.41.0-nightly (a605441e0 2019-12-15).

Checking through some different versions, these all take over a minute (I didn't bother sitting around for the full 30 minutes):

  • rustc 1.32.0 (9fda7c223 2019-01-16)
  • rustc 1.33.0 (2aa4c46cf 2019-02-28)
  • rustc 1.35.0 (3c235d560 2019-05-20)
  • rustc 1.40.0 (73528e339 2019-12-16)
  • rustc 1.42.0-nightly (859764425 2020-01-07)

Going back a little further it works and compiles in about a second on:

  • rustc 1.30.0 (da5f414c2 2018-10-24)
  • rustc 1.31.0 (abe02cefd 2018-12-04)

Going back even further it ICEs with capacity overflow on:

  • rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
  • rustc 1.21.0 (3b72af97e 2017-10-09)

(this may be a duplicate of one of the existing large array compile time issues, but I didn't find one it fit exactly with, especially given it worked on at least two stable releases).

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions