-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried a recursive function like Continuation-passing style.
I tried this code
use std::ops::Fn;
fn fact<F>(n: i64, f: F) -> i64
where F: Fn(i64) -> i64 {
match n {
1 => f(1),
_ => fact(n-1, |x|{f(n * x)}),
}
}
fn main(){
let v = fact(5, |x|{x});
println!("{:?}", v);
}
I expected the compilation would end or to see some compilation error, but the compilation is never finished without any error.
I made it simpler.
use std::ops::Fn;
fn rec<F>(f: F) -> i64
where F: Fn(i64) -> i64 {
rec(|x|{f(x)})
}
fn main(){
let _ = rec(|x|{x});
}
It also happened same problem.
Would you tell me why this problem has occured ?
Meta
rustc 1.13.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-apple-darwin
release: 1.13.0
Metadata
Metadata
Assignees
Labels
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.