Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yvt opened this issue Oct 1, 2020 · 0 comments · Fixed by #77420
Closed

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

yvt opened this issue Oct 1, 2020 · 0 comments · Fixed by #77420
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@yvt
Copy link
Contributor

yvt commented Oct 1, 2020

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)
@yvt yvt added the C-bug Category: This is a bug. label Oct 1, 2020
@ecstatic-morse ecstatic-morse added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 1, 2020
@ecstatic-morse ecstatic-morse self-assigned this Oct 1, 2020
@ecstatic-morse ecstatic-morse added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 1, 2020
@bors bors closed this as completed in 6245b95 Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants