Skip to content

Questionable const-checking for Drop with impossible bounds #163149

Description

@theemathas

Code

I tried this code:

pub struct Thing<T>(*const T) where [T]: Sized;

impl<T> Drop for Thing<T> where [T]: Sized {
    fn drop(&mut self) {}
}

// Requires dropping Thing<T> in const
pub const fn foo<T>(_x: Thing<T>) where [T]: Sized {}

This code errors in beta, with the following error:

error[E0493]: destructor of `Thing<T>` cannot be evaluated at compile-time
 --> src/lib.rs:8:21
  |
8 | pub const fn foo<T>(_x: Thing<T>) where [T]: Sized {}
  |                     ^^                              - value is dropped here
  |                     |
  |                     the destructor for this type cannot be evaluated in constant functions

For more information about this error, try `rustc --explain E0493`.

However, it compiles in nightly without any errors. It's unclear to me whether this is desirable.

Version it worked on

It failed to compile on: 1.99.0-beta.7 (2026-09-19 aa0593682acc35672839) on the playground.

Version with regression

It compiles without errors on: 1.100.0-nightly (2026-09-21 1303417c416e1595173d) on the playground.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-destructorsArea: Destructors (`Drop`, …)A-impossible-boundsArea: Issues related to have impossible trait bounds in scope (impossible predicates)C-bugCategory: This is a bug.I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions