about summary refs log tree commit diff
path: root/tests/ui/suggestions/raw-to-ref.rs
blob: 2be8f881b5c3aaafa8a41f777981a2a8f2ed784c (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 { *x };
    //~^ ERROR mismatched types
    //~| HELP consider mutably borrowing here
}