]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized-locals/borrow-after-move.rs
Don't resolve type var roots in point_at_expr_source_of_inferred_type
[rust.git] / tests / ui / unsized-locals / borrow-after-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         println!("{}", &x);
22         //~^ERROR borrow of moved value
23         println!("{}", &y);
24         //~^ERROR borrow of moved value
25     }
26
27     {
28         let x = "hello".to_owned().into_boxed_str();
29         let y = *x;
30         y.foo();
31         println!("{}", &x);
32         //~^ERROR borrow of moved value
33         println!("{}", &y);
34         //~^ERROR borrow of moved value
35     }
36
37     {
38         let x = "hello".to_owned().into_boxed_str();
39         x.foo();
40         println!("{}", &x);
41         //~^ERROR borrow of moved value
42     }
43 }