]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized-locals/double-move.rs
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
[rust.git] / tests / ui / unsized-locals / double-move.rs
1 #![feature(unsized_locals, unsized_fn_params)]
2 //~^ WARN the feature `unsized_locals` is incomplete
3
4 pub trait Foo {
5     fn foo(self) -> String;
6 }
7
8 impl Foo for str {
9     fn foo(self) -> String {
10         self.to_owned()
11     }
12 }
13
14 fn drop_unsized<T: ?Sized>(_: T) {}
15
16 fn main() {
17     {
18         let x = "hello".to_owned().into_boxed_str();
19         let y = *x;
20         drop_unsized(y);
21         drop_unsized(y); //~ERROR use of moved value
22     }
23
24     {
25         let x = "hello".to_owned().into_boxed_str();
26         let _y = *x;
27         drop_unsized(x); //~ERROR use of moved value
28     }
29
30     {
31         let x = "hello".to_owned().into_boxed_str();
32         drop_unsized(x);
33         let _y = *x; //~ERROR use of moved value
34     }
35
36     {
37         let x = "hello".to_owned().into_boxed_str();
38         let y = *x;
39         y.foo();
40         y.foo(); //~ERROR use of moved value
41     }
42
43     {
44         let x = "hello".to_owned().into_boxed_str();
45         let _y = *x;
46         x.foo(); //~ERROR use of moved value
47     }
48
49     {
50         let x = "hello".to_owned().into_boxed_str();
51         x.foo();
52         let _y = *x; //~ERROR use of moved value
53     }
54 }