1 #![feature(box_syntax)]
2 #![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
3 #![warn(clippy::boxed_local)]
24 fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
25 let boxed_local = boxed_trait;
34 fn warn_arg(x: Box<A>) {
38 fn nowarn_closure_arg() {
40 x.map_or((), |x| take_ref(&x));
43 fn warn_rename_call() {
47 y.foo(); // via autoderef
56 take_ref(&bz); // via deref coercion
59 fn nowarn_return() -> Box<A> {
60 box A // moved out, "escapes"
65 drop(bx) // moved in, "escapes"
69 bx.clone(); // method only available to Box, not via autoderef
74 take_box(&bx); // fn needs &Box
77 fn take_box(x: &Box<A>) {}
80 fn nowarn_ref_take() {
81 // false positive, should actually warn
88 let x = box A; // moved into a match
102 fn nowarn_large_array() {
103 // should not warn, is large array
104 // and should not be on stack
105 let x = box [1; 10000];
112 /// ICE regression test
117 impl<'a> Foo for &'a () {
121 pub struct PeekableSeekable<I: Foo> {
125 pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
127 /// Regression for #916, #1123
129 /// This shouldn't warn for `boxed_local`as the implementation of a trait
130 /// can't change much about the trait definition.
132 fn do_sth(self: Box<Self>);
135 impl BoxedAction for u64 {
136 fn do_sth(self: Box<Self>) {
137 println!("{}", *self)
141 /// Regression for #1478
143 /// This shouldn't warn for `boxed_local`as self itself is a box type.
148 impl<T> MyTrait for Box<T> {
152 // Issue #3739 - capture in closures
156 fn consume<T>(_: T) {}
157 fn borrow<T>(_: &T) {}
159 fn closure_consume(x: Box<A>) {
165 fn closure_borrow(x: Box<A>) {