Skip to content

rustfmt partially eats raw reference operators #4066

@ghost

Description

Input:

#![feature(raw_ref_op)]

fn main() {
    let x: i32 = 0;
    let _ = &raw const x as *const u32;

    let mut y: i32 = 0;
    let _ = &raw mut y as *mut u32;
}

Output:

#![feature(raw_ref_op)]

fn main() {
    let x: i32 = 0;
    let _ = &x as *const u32;

    let mut y: i32 = 0;
    let _ = &mut y as *mut u32;
}

The input compiles, while the output doesn't compile giving these errors:

error[E0606]: casting `&i32` as `*const u32` is invalid
error[E0606]: casting `&mut i32` as `*mut u32` is invalid

Using rustfmt 1.4.12-nightly (9f53665 2020-02-10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions