1 #![deny(clippy::borrowed_box)]
2 #![allow(clippy::blacklisted_name)]
3 #![allow(unused_variables)]
6 pub fn test1(foo: &mut Box<bool>) {
7 // Although this function could be changed to "&mut bool",
8 // avoiding the Box, mutable references to boxes are not
9 // flagged by this lint.
11 // This omission is intentional: By passing a mutable Box,
12 // the memory location of the pointed-to object could be
13 // modified. By passing a mutable reference, the contents
14 // could change, but not the location.
27 fn test4(a: &Box<bool>);
30 impl<'a> Test4 for Test3<'a> {
31 fn test4(a: &Box<bool>) {
38 pub fn test5(foo: &mut Box<dyn Any>) {
43 let foo: &Box<dyn Any>;
47 foo: &'a Box<dyn Any>,
51 fn test8(a: &Box<dyn Any>);
54 impl<'a> Test8 for Test7<'a> {
55 fn test8(a: &Box<dyn Any>) {
60 pub fn test9(foo: &mut Box<dyn Any + Send + Sync>) {
65 let foo: &Box<dyn Any + Send + 'static>;
69 foo: &'a Box<dyn Any + Send>,
73 fn test4(a: &Box<dyn Any + 'static>);
76 impl<'a> Test12 for Test11<'a> {
77 fn test4(a: &Box<dyn Any + 'static>) {
82 pub fn test13(boxed_slice: &mut Box<[i32]>) {
83 // Unconditionally replaces the box pointer.
85 // This cannot be accomplished if "&mut [i32]" is passed,
86 // and provides a test case where passing a reference to
88 let mut data = vec![12];
89 *boxed_slice = data.into_boxed_slice();
93 test1(&mut Box::new(false));
95 test5(&mut (Box::new(false) as Box<dyn Any>));
97 test9(&mut (Box::new(false) as Box<dyn Any + Send + Sync>));