Bug in lifetime checker
bvssvni opened this issue · 1 comments
bvssvni commented
fn main() {
x := 0
a := []
y := 1
foo(mut a, x, y)
}
fn foo(mut a, x: 'a, y) {
a = [x, y]
}
bvssvni commented
This can be solved by introducing LifetimeError
and LifetimeResult
:
#[derive(Debug)]
pub enum LifetimeError {
None,
FailedToUnify,
}
pub type LifetimeResult = Result<Lifetime, LifetimeError>;
The LifetimeError::FailedToUnify
is used when it is undecidable which lifetime to assign to the expression.
In most cases, one can solve these problems using clone
, so this is suggested in the error message.
This design makes a pragmatic tradeoff between practical use and computational complexity.