Skip to content

Regression in type inference of casting in constants #28801

Closed
@jethrogb

Description

@jethrogb

This works in stable, beta and nightly:

let x: *mut () = (0 as *const usize) as *const _ as *mut _;

This only works in stable:

const x: *mut () = (0 as *const usize) as *const _ as *mut _;

But in beta and nightly results in:

<anon>:2:47: 2:55 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282]
<anon>:2     const x: *mut () = (0 as *const usize) as *const _ as *mut _;

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions