Skip to content

Pointer to static is not guaranteed_eq to itself. #144584

@theemathas

Description

@theemathas

I tried this code:

#![feature(const_raw_ptr_comparison)]

static X: u64 = 1;
const B: Option<bool> = (&raw const X).guaranteed_eq(&raw const X);

fn main() {
    println!("{B:?}");
}

I expected to the code to output Some(true), but it output None.

guaranteed_eq is documented to sometimes output None on equal pointers though, so I'm not sure if this is a bug.

@rustbot labels +A-const-eval

Tracking issue: #53020

Meta

Reproducible on the playground with version 1.90.0-nightly (2025-07-27 f8e355c230c6eb7b78ff)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions