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.
10 #![warn(clippy::drop_ref, clippy::forget_ref)]
11 #![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)]
13 use std::mem::{drop, forget};
21 let mut owned1 = SomeStruct;
26 let mut owned2 = SomeStruct;
32 let reference1 = &SomeStruct;
36 let reference2 = &mut SomeStruct;
38 let reference3 = &mut SomeStruct;
41 let ref reference4 = SomeStruct;
47 fn test_generic_fn_drop<T>(val: T) {
53 fn test_generic_fn_forget<T>(val: T) {
59 fn test_similarly_named_function() {
60 fn drop<T>(_val: T) {}
61 drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name
62 std::mem::drop(&SomeStruct);
63 fn forget<T>(_val: T) {}
64 forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name
65 std::mem::forget(&SomeStruct);