Closed
Description
I tried this code:
fn main(){
let mut iter=0u8..1;
println!("begin");
func(&mut iter)
}
fn func<T:Iterator<Item=u8>>(iter:&mut T){
if let Some(x)=iter.next(){
println!("{}",x);
func(&mut iter.map(|x|x+1))
}
}
I expected to see this happen:
program either compiled successful or compiler generate an error
Instead, this happened:
rustc eats 100% CPU for several minutes, but nothing generated.
I compile this code using both
rustc testxx.rs -C opt-level=3 -C target-cpu=native -C codegen-units=1 -C lto -o testxx
andrustc testxx.rs -C opt-level=0 -o testxx
before I began to write this issue, but compiler do not compile even after this issue is submitted.
Meta
rustc --version --verbose
:
rustc 1.52.0-nightly (152f66092 2021-02-17)
binary: rustc
commit-hash: 152f6609246558be5e2582e67376194815e6ba0d
commit-date: 2021-02-17
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1
Backtrace
(cannot compile)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Trait systemCategory: This is a bug.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.High priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.