Skip to content
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

Exponential parse time involving maybe_suggest_struct_literal #105067

Open
jruderman opened this issue Nov 29, 2022 · 2 comments
Open

Exponential parse time involving maybe_suggest_struct_literal #105067

jruderman opened this issue Nov 29, 2022 · 2 comments
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

Code

fn main() {
    0 & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {
    x: y & {

Where it's slow

According to -Z time-passes, the slow pass is parse_crate.

sample-head.txt

maybe_suggest_struct_literal repeatedly on the stack is sus.

Regression

Regression in nightly-2020-10-09, most likely from #75470, which added the function maybe_suggest_struct_literal (@estebank)

Version

rustc 1.67.0-nightly (1eb62b123 2022-11-27)
binary: rustc
commit-hash: 1eb62b1235fd77200e6bd967d70e83c0f2497233
commit-date: 2022-11-27
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +I-compiletime

@jruderman jruderman added the C-bug Category: This is a bug. label Nov 29, 2022
@rustbot rustbot added the I-compiletime Issue: Problems and improvements with respect to compile times. label Nov 29, 2022
@estebank
Copy link
Contributor

We could add a flat to ensure that we don't recurse into that function given that this is meant only for error recovery and beyond a certain point all bets are off so it's better to bail early if we recognize that we don't know what we're dealing with. Ho was this found? Through fuzzing?

Also, now that I think about the approach can be changed entirely now that type ascription is no longer accepted syntax.

@estebank estebank added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 29, 2022
@jruderman
Copy link
Contributor Author

Yes, this was found through fuzzing. I'm using a fork of fuzz-rustc where I've added a custom mutator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants