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(tool_lints)]
13 #![allow(unused, clippy::trivially_copy_pass_by_ref)]
14 #![warn(clippy::mut_from_ref)]
19 fn this_wont_hurt_a_bit(&self) -> &mut Foo {
25 fn ouch(x: &Foo) -> &mut Foo;
29 fn ouch(x: &Foo) -> &mut Foo {
34 fn fail(x: &u32) -> &mut u16 {
38 fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 {
42 fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 {
46 // this is OK, because the result borrows y
47 fn works<'a>(x: &u32, y: &'a mut u32) -> &'a mut u32 {
51 // this is also OK, because the result could borrow y
52 fn also_works<'a>(x: &'a u32, y: &'a mut u32) -> &'a mut u32 {