Closed
Description
The borrow checker gives different results when functions are manually inlined, giving confusing or annoying results.
The following compiles:
struct Foo {
x: int,
y: int,
}
impl Foo {
pub fn foo(&mut self) {
let y = &mut self.y;
self.x = self.x + *y;
}
}
The following does not:
struct Foo {
x: int,
y: int,
}
impl Foo {
pub fn foo(&mut self) {
let y = self.bar();
self.x = self.x + *y;
}
pub fn bar(&mut self) -> &mut int {
&mut self.y
}
}
I don't believe this to be a duplicate of #6393, because this has not only to do with scoping, but also the fact that a member function always borrows all of self
.
Metadata
Metadata
Assignees
Labels
No labels