Skip to content

trait Sub: const Super has unusable dyn #145198

@theemathas

Description

@theemathas

I'm not sure what the correct behavior is here, but the current behavior definitely seems weird.

#![feature(const_trait_impl)]

const trait Super {}
trait Sub: const Super {
    fn method(&self);
}

fn wut(x: &dyn Sub) {
    x.method();
}
error[E0277]: the trait bound `dyn Sub: const Super` is not satisfied
 --> src/lib.rs:9:7
  |
9 |     x.method();
  |       ^^^^^^
  |
note: required by a bound in `Sub::method`
 --> src/lib.rs:4:12
  |
4 | trait Sub: const Super {
  |            ^^^^^^^^^^^ required by this bound in `Sub::method`
5 |     fn method(&self);
  |        ------ required by a bound in this associated function

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

@rustbot labels +F-const_trait_impl

Meta

Reproducible on the playground with version 1.91.0-nightly (2025-08-09 ca77504943887037504c)

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`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