about summary refs log tree commit diff
path: root/tests/ui/suggestions/raw-to-ref.fixed
blob: 17d61e67e1f619deaabf143f2c9b083154d4f014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//@ run-rustfix
// Regression test for #135580: check that we do not suggest to simply drop
// the `*` to make the types match when the source is a raw pointer while
// the target type is a reference.

struct S;

fn main() {
    let mut s = S;
    let x = &raw const s;
    let _: &S = unsafe { &*x };
    //~^ ERROR mismatched types
    //~| HELP consider borrowing here

    let x = &raw mut s;
    let _: &mut S = unsafe { &mut *x };
    //~^ ERROR mismatched types
    //~| HELP consider mutably borrowing here
}