]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrow_box.rs
Merge pull request #1963 from rust-lang-nursery/upstream
[rust.git] / tests / ui / borrow_box.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(borrowed_box)]
5 #![allow(blacklisted_name)]
6 #![allow(unused_variables)]
7 #![allow(dead_code)]
8
9 pub fn test1(foo: &mut Box<bool>) {
10     println!("{:?}", foo)
11 }
12
13 pub fn test2() {
14     let foo: &Box<bool>;
15 }
16
17 struct Test3<'a> {
18     foo: &'a Box<bool>
19 }
20
21 trait Test4 {
22     fn test4(a: &Box<bool>);
23 }
24
25 impl<'a> Test4 for Test3<'a> {
26     fn test4(a: &Box<bool>) {
27         unimplemented!();
28     }
29 }
30
31 use std::any::Any;
32
33 pub fn test5(foo: &mut Box<Any>) {
34     println!("{:?}", foo)
35 }
36
37 pub fn test6() {
38     let foo: &Box<Any>;
39 }
40
41 struct Test7<'a> {
42     foo: &'a Box<Any>
43 }
44
45 trait Test8 {
46     fn test8(a: &Box<Any>);
47 }
48
49 impl<'a> Test8 for Test7<'a> {
50     fn test8(a: &Box<Any>) {
51         unimplemented!();
52     }
53 }
54
55 pub fn test9(foo: &mut Box<Any + Send + Sync>) {
56     let _ = foo;
57 }
58
59 pub fn test10() {
60     let foo: &Box<Any + Send + 'static>;
61 }
62
63 struct Test11<'a> {
64     foo: &'a Box<Any + Send>
65 }
66
67 trait Test12 {
68     fn test4(a: &Box<Any + 'static>);
69 }
70
71 impl<'a> Test12 for Test11<'a> {
72     fn test4(a: &Box<Any + 'static>) {
73         unimplemented!();
74     }
75 }
76
77 fn main(){
78     test1(&mut Box::new(false));
79     test2();
80     test5(&mut (Box::new(false) as Box<Any>));
81     test6();
82     test9(&mut (Box::new(false) as Box<Any + Send + Sync>));
83     test10();
84 }