Skip to content

poor error message when casting from fat raw pointer to usize #27450

@durka

Description

@durka

playpen

trait Num {}
impl Num for i32 {}

fn main() {
    &0i32 as *const Num as usize;
}

This compiles on stable, but beta and nightly require an extra as *const () in the middle to cast away the fat. The error message says to use a "raw pointer" which is misleading as *const Num is already a raw pointer, it's just a fat one.

Since this code compiles on stable, I'm not sure if it's also a regression or if I missed an RFC (to be fair, I miss a lot of RFCs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions