forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![feature(nll)] | ||
|
||
pub trait Foo { | ||
fn zero(self) -> Self; | ||
} | ||
|
||
impl Foo for u32 { | ||
fn zero(self) -> u32 { 0u32 } | ||
} | ||
|
||
pub mod bar { | ||
pub use Foo; | ||
pub fn bar<T: Foo>(x: T) -> T { | ||
x.zero() | ||
} | ||
} | ||
|
||
mod baz { | ||
use bar; | ||
use Foo; | ||
pub fn baz<T: Foo>(x: T) -> T { | ||
if 0 == 1 { | ||
bar::bar(x.zero()) | ||
} else { | ||
x.zero() | ||
}; | ||
x.zero() | ||
//~^ ERROR use of moved value | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = baz::baz(0u32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0382]: use of moved value: `x` | ||
--> $DIR/issue-34721.rs:27:9 | ||
| | ||
LL | pub fn baz<T: Foo>(x: T) -> T { | ||
| - move occurs because `x` has type `T`, which does not implement the `Copy` trait | ||
LL | if 0 == 1 { | ||
LL | bar::bar(x.zero()) | ||
| - value moved here | ||
LL | } else { | ||
LL | x.zero() | ||
| - value moved here | ||
LL | }; | ||
LL | x.zero() | ||
| ^ value used here after move | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |