1 #![feature(box_syntax)]
4 clippy::needless_pass_by_value,
6 clippy::redundant_clone
8 #![warn(clippy::boxed_local)]
29 fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
30 let boxed_local = boxed_trait;
39 fn warn_arg(x: Box<A>) {
43 fn nowarn_closure_arg() {
45 x.map_or((), |x| take_ref(&x));
48 fn warn_rename_call() {
52 y.foo(); // via autoderef
61 take_ref(&bz); // via deref coercion
64 fn nowarn_return() -> Box<A> {
65 box A // moved out, "escapes"
70 drop(bx) // moved in, "escapes"
74 bx.clone(); // method only available to Box, not via autoderef
79 take_box(&bx); // fn needs &Box
82 fn take_box(x: &Box<A>) {}
85 fn nowarn_ref_take() {
86 // false positive, should actually warn
93 let x = box A; // moved into a match
107 fn nowarn_large_array() {
108 // should not warn, is large array
109 // and should not be on stack
110 let x = box [1; 10000];
117 /// ICE regression test
122 impl<'a> Foo for &'a () {
126 pub struct PeekableSeekable<I: Foo> {
130 pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
132 /// Regression for #916, #1123
134 /// This shouldn't warn for `boxed_local`as the implementation of a trait
135 /// can't change much about the trait definition.
137 fn do_sth(self: Box<Self>);
140 impl BoxedAction for u64 {
141 fn do_sth(self: Box<Self>) {
142 println!("{}", *self)
146 /// Regression for #1478
148 /// This shouldn't warn for `boxed_local`as self itself is a box type.
153 impl<T> MyTrait for Box<T> {
157 // Issue #3739 - capture in closures
161 fn consume<T>(_: T) {}
162 fn borrow<T>(_: &T) {}
164 fn closure_consume(x: Box<A>) {
170 fn closure_borrow(x: Box<A>) {