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 #![allow(unused_variables, clippy::trivially_copy_pass_by_ref)]
12 fn takes_an_immutable_reference(a: &i32) {}
13 fn takes_a_mutable_reference(a: &mut i32) {}
18 fn takes_an_immutable_reference(&self, a: &i32) {}
20 fn takes_a_mutable_reference(&self, a: &mut i32) {}
23 #[warn(clippy::unnecessary_mut_passed)]
26 takes_an_immutable_reference(&mut 42);
27 let as_ptr: fn(&i32) = takes_an_immutable_reference;
31 let my_struct = MyStruct;
32 my_struct.takes_an_immutable_reference(&mut 42);
37 takes_an_immutable_reference(&42);
38 let as_ptr: fn(&i32) = takes_an_immutable_reference;
41 takes_a_mutable_reference(&mut 42);
42 let as_ptr: fn(&mut i32) = takes_a_mutable_reference;
46 takes_an_immutable_reference(a);
49 my_struct.takes_an_immutable_reference(&42);
50 my_struct.takes_a_mutable_reference(&mut 42);
51 my_struct.takes_an_immutable_reference(a);