rust-lang/rust

Compiler is still slow in rejecting "Invalid left-hand side of assignment"

jruderman opened this issue · 1 comments

rustc takes 75ms to reject each line of 1 = ();.

Testcase (100 repetitions)

fn main() {
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
    1 = ();
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (dcb376115 2022-10-20)
binary: rustc
commit-hash: dcb376115066d111dbf5f13d5ac2a2dbe8c12add
commit-date: 2022-10-20
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Observations

  • This is left over from #103219. Now it's linear (not exponential), but the constant factor is very high.
  • The slow pass is still item_bodies_checking.
  • Nearly 100% of the time is spent in probe_for_return_type.
  • I flattened this testcase from 1 = 1 = ... = 1; to repeats of 1 = ();. This doesn't affect the speed, but may make the sample tree easier to read.
  • It becomes 5x faster if I add #![no_std]. This strikes me as odd because I wouldn't expect anything in std to make this assignment valid.

@rustbot label +I-compiletime

I personally don't think we need to optimize diagnostics code, especially cases grows linearly in time with the number of repetitions -- plenty of other diagnostics do expensive computations in their attempt to suggest help.