Skip to content

Commit b78f660

Browse files
committed
test(toolchain_limitations): impl const Trait now requires #[const_trait]
`[ref:const_impl_of_non_const_trait]` has been resolved by [rust-lang/rust#100982][1]. [1]: rust-lang/rust#100982
1 parent 3b7d008 commit b78f660

File tree

1 file changed

+2
-46
lines changed

1 file changed

+2
-46
lines changed

doc/toolchain_limitations.md

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -499,27 +499,13 @@ const _: () = assert!(matches!((2..4).next(), Some(2)));
499499

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

502-
```rust
502+
```rust,compile_fail
503503
#![feature(const_trait_impl)]
504504
#![feature(const_mut_refs)]
505-
// FIXME: `compile-fail` temporarily removed due to
506-
// [ref:const_impl_of_non_const_trait]
507505
508506
struct MyIterator;
509507
510-
// error: const trait implementations may not use non-const default functions
511-
// note: `size_hint`, `count`, `last`, `advance_by`, `nth`, `step_by`, `chain`,
512-
// `zip`, `intersperse`, `intersperse_with`, `map`, `for_each`, `filter`,
513-
// `filter_map`, `enumerate`, `peekable`, `skip_while`, `take_while`,
514-
// `map_while`, `skip`, `take`, `scan`, `flat_map`, `flatten`, `fuse`,
515-
// `inspect`, `by_ref`, `collect`, `try_collect`, `partition`,
516-
// `partition_in_place`, `is_partitioned`, `try_fold`, `try_for_each`, `fold`,
517-
// `reduce`, `try_reduce`, `all`, `any`, `find`, `find_map`, `try_find`,
518-
// `position`, `rposition`, `max`, `min`, `max_by_key`, `max_by`, `min_by_key`,
519-
// `min_by`, `rev`, `unzip`, `copied`, `cloned`, `cycle`, `sum`, `product`,
520-
// `cmp`, `cmp_by`, `partial_cmp`, `partial_cmp_by`, `eq`, `eq_by`, `ne`, `lt`,
521-
// `le`, `gt`, `ge`, `is_sorted`, `is_sorted_by`, `is_sorted_by_key`,
522-
// `__iterator_get_unchecked` not implemented
508+
// error: const `impl` for trait `Iterator` which is not marked with `#[const_trait]`
523509
impl const Iterator for MyIterator {
524510
type Item = u32;
525511
@@ -530,36 +516,6 @@ impl const Iterator for MyIterator {
530516
```
531517

532518

533-
### `[tag:const_impl_of_non_const_trait]` `impl const Trait` doesn't require `#[const_trait]`
534-
535-
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.
536-
537-
```rust
538-
#![feature(const_trait_impl)]
539-
trait Tr {
540-
fn foo() {}
541-
}
542-
543-
// expected error: const trait implementations may not use non-const default
544-
// functions / note: `foo` not implemented
545-
impl const Tr for () {}
546-
```
547-
548-
```rust
549-
#![feature(const_trait_impl)]
550-
#![feature(lint_reasons)]
551-
trait Tr {
552-
fn foo() {}
553-
}
554-
555-
impl const Tr for () {}
556-
557-
const fn f<T: ~const Tr>() { T::foo() }
558-
#[expect(const_err)] // error: calling non-const function `<() as Tr>::foo`
559-
const _: () = f::<()>();
560-
```
561-
562-
563519
### `[tag:const_assert_eq]` `assert_eq!` and similar macros are unusable in `const fn`
564520

565521
```rust,compile_fail,E0015

0 commit comments

Comments
 (0)