rust-lang / rust-lang/rustfmt

rustfmt hangs

Open
#5,626 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-closures C-bug P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

// run-pass

pub fn main() { return isize(); }

pub mod foo {
    pub fn f() -> isize { return 2; }
    pub fn g() {
||||||||||||||H||||isize||||||||||||||(|| ||||isize||||||||||||||||isize||||||||||||||||||||||||||        isize!(f(), 2))();
        isize!(::f(), 1);
    }
}

pub fn main() { return ||||||||||||||H||||isize||||||||||||||(|| ||||H||||||||||||||||isize||||||||||||||||||||||||||        isize!(f(), 2))(); }

While rustc throws errors after 0.2 seconds, rustfmt (cargo fmt) seems to crunch this indefinitely (I gave up after 15 minutes) with no output whatsoever.

A lot of processing by
<rustfmt_nightly::comment::UngroupedCommentCodeSlices as core::iter::traits::iterator::Iterator>::next and <rustfmt_nightly::comment::CharClasses<core::str::iter::CharIndices> as core::iter::traits::iterator::Iterator>::next

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the Rust snippet in the report by running cargo fmt, then inspect rustfmt_nightly::comment::UngroupedCommentCodeSlices::next and CharClasses<CharIndices>::next, where profiling shows most processing. Done means rustfmt no longer runs indefinitely on this input and instead completes with observable output or an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.