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