Skip to content

With allow(const_err), diagnostics are not very helpful #65597

Closed
@RalfJung

Description

@RalfJung

Consider:

#![allow(const_err)]

union Trans { i: usize, o: &'static u32 }

const C: () = unsafe { let _val = *Trans { i: 4 }.o; () };

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

This deref's a dangling pointer, but due to allow(const_err) the only diagnostic we get is

error[E0080]: evaluation of constant expression failed
 --> src/main.rs:8:22
  |
8 |     println!("{:?}", C);
  |                      ^ referenced constant has errors

error: aborting due to previous error

Making this an allowable lint is not very helpful when later follow-on errors are hard errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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