1 #![warn(clippy::drop_ref, clippy::forget_ref)]
2 #![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)]
4 use std::mem::{drop, forget};
12 let mut owned1 = SomeStruct;
17 let mut owned2 = SomeStruct;
23 let reference1 = &SomeStruct;
27 let reference2 = &mut SomeStruct;
29 let reference3 = &mut SomeStruct;
32 let ref reference4 = SomeStruct;
38 fn test_generic_fn_drop<T>(val: T) {
44 fn test_generic_fn_forget<T>(val: T) {
50 fn test_similarly_named_function() {
51 fn drop<T>(_val: T) {}
52 drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name
53 std::mem::drop(&SomeStruct);
54 fn forget<T>(_val: T) {}
55 forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name
56 std::mem::forget(&SomeStruct);
59 #[derive(Copy, Clone)]
61 fn produce_half_owl_error() -> Result<(), Error> {
65 fn produce_half_owl_ok() -> Result<bool, ()> {
70 fn test_owl_result() -> Result<(), ()> {
71 produce_half_owl_error().map_err(|_| ())?;
72 produce_half_owl_ok().map(|_| ())?;
73 // the following should not be linted,
74 // we should not force users to use toilet closures
75 // to produce owl results when drop is more convenient
76 produce_half_owl_error().map_err(drop)?;
77 produce_half_owl_ok().map_err(drop)?;
82 fn test_owl_result_2() -> Result<u8, ()> {
83 produce_half_owl_error().map_err(|_| ())?;
84 produce_half_owl_ok().map(|_| ())?;
85 // the following should not be linted,
86 // we should not force users to use toilet closures
87 // to produce owl results when drop is more convenient
88 produce_half_owl_error().map_err(drop)?;
89 produce_half_owl_ok().map(drop)?;