You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A `const` implementation of a non-`#[const_trait]` trait that uses at least one default method implementation doesn't result in a compile error. Instead, an error occurs when the non-`const` default method implementations are actually called in a constant context. This behavior deviates from Rust's design principles, so it's likely a bug.
554
+
555
+
```rust
556
+
#![feature(const_trait_impl)]
557
+
traitTr {
558
+
fnfoo() {}
559
+
}
560
+
561
+
// expected error: const trait implementations may not use non-const default
562
+
// functions / note: `foo` not implemented
563
+
implconstTrfor () {}
564
+
```
565
+
566
+
```rust
567
+
#![feature(const_trait_impl)]
568
+
#![feature(lint_reasons)]
569
+
traitTr {
570
+
fnfoo() {}
571
+
}
572
+
573
+
implconstTrfor () {}
574
+
575
+
constfnf<T: ~constTr>() { T::foo() }
576
+
#[expect(const_err)] // error: calling non-const function `<() as Tr>::foo`
577
+
const_: () =f::<()>();
578
+
```
579
+
580
+
549
581
### `[tag:int_const_ord]``<integer>: !const Ord`
550
582
551
583
The standard library doesn't provide `const` trait implementations of `Ord` for the built-in integer types.
0 commit comments