File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( nll) ]
2+
3+ pub trait Foo {
4+ fn zero ( self ) -> Self ;
5+ }
6+
7+ impl Foo for u32 {
8+ fn zero ( self ) -> u32 { 0u32 }
9+ }
10+
11+ pub mod bar {
12+ pub use Foo ;
13+ pub fn bar < T : Foo > ( x : T ) -> T {
14+ x. zero ( )
15+ }
16+ }
17+
18+ mod baz {
19+ use bar;
20+ use Foo ;
21+ pub fn baz < T : Foo > ( x : T ) -> T {
22+ if 0 == 1 {
23+ bar:: bar ( x. zero ( ) )
24+ } else {
25+ x. zero ( )
26+ } ;
27+ x. zero ( )
28+ //~^ ERROR use of moved value
29+ }
30+ }
31+
32+ fn main ( ) {
33+ let _ = baz:: baz ( 0u32 ) ;
34+ }
Original file line number Diff line number Diff line change 1+ error[E0382]: use of moved value: `x`
2+ --> $DIR/issue-34721.rs:27:9
3+ |
4+ LL | pub fn baz<T: Foo>(x: T) -> T {
5+ | - move occurs because `x` has type `T`, which does not implement the `Copy` trait
6+ LL | if 0 == 1 {
7+ LL | bar::bar(x.zero())
8+ | - value moved here
9+ LL | } else {
10+ LL | x.zero()
11+ | - value moved here
12+ LL | };
13+ LL | x.zero()
14+ | ^ value used here after move
15+
16+ error: aborting due to previous error
17+
18+ For more information about this error, try `rustc --explain E0382`.
You can’t perform that action at this time.
0 commit comments