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.
14 #![allow(unused_variables, clippy::trivially_copy_pass_by_ref)]
16 fn takes_an_immutable_reference(a: &i32) {}
17 fn takes_a_mutable_reference(a: &mut i32) {}
22 fn takes_an_immutable_reference(&self, a: &i32) {
25 fn takes_a_mutable_reference(&self, a: &mut i32) {
29 #[warn(clippy::unnecessary_mut_passed)]
32 takes_an_immutable_reference(&mut 42);
33 let as_ptr: fn(&i32) = takes_an_immutable_reference;
37 let my_struct = MyStruct;
38 my_struct.takes_an_immutable_reference(&mut 42);
44 takes_an_immutable_reference(&42);
45 let as_ptr: fn(&i32) = takes_an_immutable_reference;
48 takes_a_mutable_reference(&mut 42);
49 let as_ptr: fn(&mut i32) = takes_a_mutable_reference;
53 takes_an_immutable_reference(a);
56 my_struct.takes_an_immutable_reference(&42);
57 my_struct.takes_a_mutable_reference(&mut 42);
58 my_struct.takes_an_immutable_reference(a);