Skip to content

1.95 beta regression: trait method calls in dead code in const contexts started being rejected if the impl is not const #153765

@theemathas

Description

@theemathas

Regression found in the 1.95.0 beta crater run.

[INFO] [stdout] error[E0277]: the trait bound `Wrapper<u64>: const Deref` is not satisfied
[INFO] [stdout]    --> src/lib.rs:170:29
[INFO] [stdout]     |
[INFO] [stdout] 170 |         let _ : $field_ty = $unreachable_obj.$field;
[INFO] [stdout]     |                             ^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] ...
[INFO] [stdout] 226 |     assert_has_field!(Point2, x :~ &'static u64);
[INFO] [stdout]     |     -------------------------------------------- in this macro invocation
[INFO] [stdout]     |
[INFO] [stdout]     = note: this error originates in the macro `assert_has_field` (in Nightly builds, run with -Z macro-backtrace for more info)
[INFO] [stdout] help: make the `impl` of trait `Deref` `const`
[INFO] [stdout]     |
[INFO] [stdout] 212 |     impl<T> const core::ops::Deref for Wrapper<T> {
[INFO] [stdout]     |             +++++
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] For more information about this error, try `rustc --explain E0277`.

https://crater-reports.s3.amazonaws.com/beta-1.95-1/beta-2026-03-05/gh/JohnScience.assert_has_field/log.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.I-types-nominatedNominated for discussion during a types team meeting.S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions