1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
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.
11 #![feature(box_syntax)]
13 #![allow(warnings, clippy)]
37 fn ok_box_trait(boxed_trait: &Box<Z>) {
38 let boxed_local = boxed_trait;
47 fn warn_arg(x: Box<A>) {
51 fn nowarn_closure_arg() {
53 x.map_or((), |x| take_ref(&x));
56 fn warn_rename_call() {
60 y.foo(); // via autoderef
69 take_ref(&bz); // via deref coercion
72 fn nowarn_return() -> Box<A> {
74 fx // moved out, "escapes"
79 drop(bx) // moved in, "escapes"
83 bx.clone(); // method only available to Box, not via autoderef
88 take_box(&bx); // fn needs &Box
92 fn take_box(x: &Box<A>) {}
96 fn nowarn_ref_take() {
97 // false positive, should actually warn
104 let x = box A; // moved into a match
112 match &x { // not moved
117 fn nowarn_large_array() {
118 // should not warn, is large array
119 // and should not be on stack
120 let x = box [1; 10000];
121 match &x { // not moved
127 /// ICE regression test
132 impl<'a> Foo for &'a () {
136 pub struct PeekableSeekable<I: Foo> {
140 pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {