Skip to content

Endless Compilation when Successive Calling to map #116780

Closed
@iamanonymouscs

Description

@iamanonymouscs

cat hang.rs

#![crate_type = "lib"]
#[no_mangle]
pub fn get_len() -> usize {
    [1, 2, 3].iter(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map().collect::<Vec<_>>().len()
}

I expected to see this happen: The compiler compiles successfully or outputs an error message.

Instead, this happened: The code, as provided below, appears to encounter a hang

Command

rustc -C opt-level=0 hang.rs

Meta

rustc --version --verbose:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2

The same problem is reproduced on the nightly version(2023-10-15;42b1224e9eb37177f608d3f6a6f2be2ee13902e4)

Backtrace

error[E0061]: this method takes 0 arguments but 1 argument was supplied
 --> hang.rs:4:15
  |
4 |     [1, 2, 3].iter(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| x).map(|x| ...
  |               ^^^^ -----
  |                    |
  |                    unexpected argument of type `[closure@hang.rs:4:20: 4:23]`
  |                    help: remove the extra argument
  |
note: method defined here
 --> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/slice/mod.rs:1001:12

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions