]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/mut_from_ref.rs
1 #![allow(unused, clippy::needless_lifetimes)]
2 #![warn(clippy::mut_from_ref)]
7 fn this_wont_hurt_a_bit(&self) -> &mut Foo
{
8 unsafe { unimplemented!() }
13 fn ouch(x
: &Foo
) -> &mut Foo
;
17 fn ouch(x
: &Foo
) -> &mut Foo
{
18 unsafe { unimplemented!() }
22 fn fail(x
: &u32) -> &mut u16 {
23 unsafe { unimplemented!() }
26 fn fail_lifetime
<'a
>(x
: &'a
u32, y
: &mut u32) -> &'a
mut u32 {
27 unsafe { unimplemented!() }
30 fn fail_double
<'a
, 'b
>(x
: &'a
u32, y
: &'a
u32, z
: &'b
mut u32) -> &'a
mut u32 {
31 unsafe { unimplemented!() }
34 // this is OK, because the result borrows y
35 fn works
<'a
>(x
: &u32, y
: &'a
mut u32) -> &'a
mut u32 {
36 unsafe { unimplemented!() }
39 // this is also OK, because the result could borrow y
40 fn also_works
<'a
>(x
: &'a
u32, y
: &'a
mut u32) -> &'a
mut u32 {
41 unsafe { unimplemented!() }
44 unsafe fn also_broken(x
: &u32) -> &mut u32 {
48 fn without_unsafe(x
: &u32) -> &mut u32 {