Closed
Description
This builds fine:
struct Foo;
fn bar<'a>(foo: &'a mut Foo) -> &'a mut Foo {
{ let _ = foo; }
foo
}
But changing _
to _bar
causes it to fail:
struct Foo;
fn bar<'a>(foo: &'a mut Foo) -> &'a mut Foo {
{ let _bar = foo; }
foo
}
fn main() {
bar(&mut Foo);
}
<anon>:5:3: 5:6 error: use of moved value: `*foo` [E0382]
<anon>:5 foo
^~~
<anon>:5:3: 5:6 help: see the detailed explanation for E0382
<anon>:4:9: 4:13 note: `foo` moved here because it has type `&mut Foo`, which is moved by default
<anon>:4 { let _bar = foo; }
^~~~
<anon>:4:9: 4:13 help: if you would like to borrow the value instead, use a `ref` binding as shown:
<anon>: { let ref _bar = foo; }
error: aborting due to previous error
playpen: application terminated with error code 101
https://play.rust-lang.org/?gist=93507eb0a792a0d7842d&version=stable
Metadata
Metadata
Assignees
Labels
No labels