Skip to content

Commit 363a19e

Browse files
committed
test(toolchain_limitations): temporarily disable the test of [ref:iterator_const_default]
> 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.
1 parent 6136058 commit 363a19e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

doc/toolchain_limitations.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,11 @@ const _: () = assert!(matches!((2..4).next(), Some(2)));
517517

518518
Implementing `const Iterator` requires you to implement all of its methods, which is impossible to do correctly.
519519

520-
```rust,compile_fail
520+
```rust
521521
#![feature(const_trait_impl)]
522522
#![feature(const_mut_refs)]
523+
// FIXME: `compile-fail` temporarily removed due to
524+
// [ref:const_impl_of_non_const_trait]
523525

524526
struct MyIterator;
525527

@@ -546,6 +548,36 @@ impl const Iterator for MyIterator {
546548
```
547549

548550

551+
### `[tag:const_impl_of_non_const_trait]` `impl const Trait` doesn't require `#[const_trait]`
552+
553+
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+
trait Tr {
558+
fn foo() {}
559+
}
560+
561+
// expected error: const trait implementations may not use non-const default
562+
// functions / note: `foo` not implemented
563+
impl const Tr for () {}
564+
```
565+
566+
```rust
567+
#![feature(const_trait_impl)]
568+
#![feature(lint_reasons)]
569+
trait Tr {
570+
fn foo() {}
571+
}
572+
573+
impl const Tr for () {}
574+
575+
const fn f<T: ~const Tr>() { T::foo() }
576+
#[expect(const_err)] // error: calling non-const function `<() as Tr>::foo`
577+
const _: () = f::<()>();
578+
```
579+
580+
549581
### `[tag:int_const_ord]` `<integer>: !const Ord`
550582

551583
The standard library doesn't provide `const` trait implementations of `Ord` for the built-in integer types.

0 commit comments

Comments
 (0)