Skip to content

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

Closed
@jruderman

Description

@jruderman

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 Exponential compilation time on chained "invalid left-hand side of assignment" #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions