]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrow_box.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / borrow_box.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #![deny(clippy::borrowed_box)]
11 #![allow(clippy::blacklisted_name)]
12 #![allow(unused_variables)]
13 #![allow(dead_code)]
14
15 pub fn test1(foo: &mut Box<bool>) {
16     println!("{:?}", foo)
17 }
18
19 pub fn test2() {
20     let foo: &Box<bool>;
21 }
22
23 struct Test3<'a> {
24     foo: &'a Box<bool>,
25 }
26
27 trait Test4 {
28     fn test4(a: &Box<bool>);
29 }
30
31 impl<'a> Test4 for Test3<'a> {
32     fn test4(a: &Box<bool>) {
33         unimplemented!();
34     }
35 }
36
37 use std::any::Any;
38
39 pub fn test5(foo: &mut Box<Any>) {
40     println!("{:?}", foo)
41 }
42
43 pub fn test6() {
44     let foo: &Box<Any>;
45 }
46
47 struct Test7<'a> {
48     foo: &'a Box<Any>,
49 }
50
51 trait Test8 {
52     fn test8(a: &Box<Any>);
53 }
54
55 impl<'a> Test8 for Test7<'a> {
56     fn test8(a: &Box<Any>) {
57         unimplemented!();
58     }
59 }
60
61 pub fn test9(foo: &mut Box<Any + Send + Sync>) {
62     let _ = foo;
63 }
64
65 pub fn test10() {
66     let foo: &Box<Any + Send + 'static>;
67 }
68
69 struct Test11<'a> {
70     foo: &'a Box<Any + Send>,
71 }
72
73 trait Test12 {
74     fn test4(a: &Box<Any + 'static>);
75 }
76
77 impl<'a> Test12 for Test11<'a> {
78     fn test4(a: &Box<Any + 'static>) {
79         unimplemented!();
80     }
81 }
82
83 fn main() {
84     test1(&mut Box::new(false));
85     test2();
86     test5(&mut (Box::new(false) as Box<Any>));
87     test6();
88     test9(&mut (Box::new(false) as Box<Any + Send + Sync>));
89     test10();
90 }