Consider the following rust program:
fn f<'a>(x: &'a i32) {
unimplemented!();
}
fn main() {
f::<'static>;
}
When compiling it, the following compilation error is outputed:
error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> src/main.rs:6:9
|
6 | f::<'static>;
| ^^^^^^^
|
note: the late bound lifetime parameter is introduced here
--> src/main.rs:1:6
|
1 | fn f<'a>(x: &'a i32) {
| ^^
Lets modify the program like this:
fn f<'a, 'b>(x: &'a i32) -> &'b i32 {
unimplemented!();
}
fn main() {
f::<'static>;
}
For some strange reason this compiles now without any compilation errors. Why is this? If the lifetime parameter 'a in the first program was late bound, why shouldn't it also be late bound in the second program? Note that the only change I did between the first and the second program was to add another lifetime parameter and a return type that depends on this new lifetime parameter.