Skip to content

Feature const_mut_refs incorrectly suggested for the use of raw_mut! in static #77414

Closed

Description

I tried this code:

#![feature(const_raw_ptr_to_usize_cast)]
#![feature(const_mut_refs)]
#![feature(raw_ref_macros)]
#![no_std]

static mut X: u32 = 0;

static P: usize = unsafe { core::ptr::raw_mut!(X) as usize };

I expected to see this happen: The code either compiles successfully or fails to compile with a reasonable error message

Instead, this happened:

error[E0658]: `&raw mut` is not allowed in statics
 --> src/lib.rs:8:28
  |
8 | static P: usize = unsafe { core::ptr::raw_mut!(X) as usize };
  |                            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
  = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

But the code already includes #![feature(const_mut_refs)].

Meta

rustc --version --verbose:

rustc 1.48.0-nightly (381b445ff 2020-09-29)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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