Skip to content

Some unstable const features do not indicate the right feature flag in their diagnostics #71797

@RalfJung

Description

@RalfJung
Member

Generally, when one does something on nightly that would work with a feature gate, but the feature gate is missing, the error should indicate the missing gate. For some const features, that is currently not the case, for example:

#![feature(const_raw_ptr_deref)]
// missing gate: #![feature(const_mut_refs)]

const WRITE: () = unsafe {
    *std::ptr::null_mut() = 0;
};

fn main() {
}
error[E0019]: constant contains unimplemented expression type
 --> src/main.rs:5:5
  |
5 |     *std::ptr::null_mut() = 0;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

This got triggered by #71630, but is orthogonal to the discussion around the unleash flag in #71631.

(I did not try to exhaustively explore this issue for all const gates.)

Cc @rust-lang/wg-const-eval

This issue has been assigned to @mibac138 via this comment.

Activity

added
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
A-diagnosticsArea: Messages for errors, warnings, and lints
requires-nightlyThis issue requires a nightly compiler in some way.
on May 2, 2020
added
D-papercutDiagnostics: An error or lint that needs small tweaks.
D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 2, 2020
mibac138

mibac138 commented on May 4, 2020

@mibac138
Contributor

@rustbot claim

self-assigned this
on May 4, 2020
added a commit that references this issue on May 4, 2020
ad74ce9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @RalfJung@estebank@mibac138@rustbot

    Issue actions

      Some unstable const features do not indicate the right feature flag in their diagnostics · Issue #71797 · rust-lang/rust