Skip to content

In const fn in a macro call, raw ptr deref does not work even inside unsafe #75340

Closed
@RalfJung

Description

@RalfJung

The following code should build, but for some reason it does not:

#![feature(const_raw_ptr_deref)]
#![feature(raw_ref_macros)]

use std::ptr;

const fn test_fn(x: *const i32) {
    let x2 = unsafe { ptr::raw_const!(*x) };
}

Removing the const or adding a const_fn feature gate makes it build.

Cc @oli-obk @petrochenkov

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)E-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