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

Constant value evaluation failure prints debug representation #138730

Closed
euclio opened this issue Mar 20, 2025 · 0 comments · Fixed by #138732
Closed

Constant value evaluation failure prints debug representation #138730

euclio opened this issue Mar 20, 2025 · 0 comments · Fixed by #138732
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@euclio
Copy link
Contributor

euclio commented Mar 20, 2025

Code

extern "C" {
    static FOO: i32;
}

const BAR: i32 = FOO;

Current output

error[E0080]: evaluation of constant value failed
 --> src/lib.rs:5:18
  |
5 | const BAR: i32 = FOO;
  |                  ^^^ cannot access extern static (DefId(0:4 ~ playground[6412]::{extern#0}::FOO))

error[E0133]: use of extern static is unsafe and requires unsafe function or block
 --> src/lib.rs:5:18
  |
5 | const BAR: i32 = FOO;
  |                  ^^^ use of extern static
  |
  = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior

Some errors have detailed explanations: E0080, E0133.
For more information about an error, try `rustc --explain E0080`.

Desired output

error[E0080]: evaluation of constant value failed
 --> src/lib.rs:5:18
  |
5 | const BAR: i32 = FOO;
  |                  ^^^ cannot access extern static

error[E0133]: use of extern static is unsafe and requires unsafe function or block
 --> src/lib.rs:5:18
  |
5 | const BAR: i32 = FOO;
  |                  ^^^ use of extern static
  |
  = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior

Some errors have detailed explanations: E0080, E0133.
For more information about an error, try `rustc --explain E0080`.

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.85.1 (4eb161250 2025-03-15)
binary: rustc
commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181
commit-date: 2025-03-15
host: x86_64-unknown-linux-gnu
release: 1.85.1
LLVM version: 19.1.7

Anything else?

No response

@euclio euclio added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 20, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 20, 2025
Use `def_path_str` for def id arg in `UnsupportedOpInfo`

We could alternatively just omit the def path from the label, but I think it's fine to keep around

Fixes rust-lang#138730
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 20, 2025
Use `def_path_str` for def id arg in `UnsupportedOpInfo`

We could alternatively just omit the def path from the label, but I think it's fine to keep around

Fixes rust-lang#138730
@bors bors closed this as completed in 55fa3f7 Mar 21, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 21, 2025
Rollup merge of rust-lang#138732 - compiler-errors:did, r=jieyouxu

Use `def_path_str` for def id arg in `UnsupportedOpInfo`

We could alternatively just omit the def path from the label, but I think it's fine to keep around

Fixes rust-lang#138730
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 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.

1 participant