Closed
Description
The following code gives a borrow checker error because the borrow of a
in the result of a.foo()
overlaps with the mutable borrow of a.bar()
:
struct A<S>;
impl<S> A<S> {
fn foo<'a>(&'a self) -> Option<&'a uint> { None }
fn bar(&mut self) { }
}
fn baz<S>(a: &mut A<S>) -> bool {
match a.foo() {
Some(i) => true,
None => { a.bar(); false }
}
}
The borrow checker should be able to recognize that the None
alternative of matching an Option<&T>
can't contain a borrowed pointer.
Metadata
Metadata
Assignees
Labels
No labels