From 67972c7c2a55bc30e789e1902caf8c1500f34db5 Mon Sep 17 00:00:00 2001 From: yvt Date: Wed, 9 Nov 2022 12:34:32 +0900 Subject: [PATCH] refactor(core): associated types can now imply `~const Trait` `[ref:const_trait_not_implied]` has been resolved by [rust-lang/rust#101989][1]. [1]: https://github.com/rust-lang/rust/pull/101989 --- doc/toolchain_limitations.md | 29 ----------------------------- src/r3_core/src/bind/sorter.rs | 4 ---- 2 files changed, 33 deletions(-) diff --git a/doc/toolchain_limitations.md b/doc/toolchain_limitations.md index f1a89f817e..f2b839e473 100644 --- a/doc/toolchain_limitations.md +++ b/doc/toolchain_limitations.md @@ -130,35 +130,6 @@ const A: MaybeUninit<*mut ()> = unsafe { ``` -### `[tag:const_trait_not_implied]` `~const` in associated type bounds are not implied in the trait's use sites - -Associated type bounds are usually implied in the trait's use sites (e.g., if an associated type `Trait::Proj` is bounded by `Clone`, `T: Trait` implies `T::Proj: Clone`). However, this doesn't seem to apply to `~const`. - -```rust -trait Trait { - type Proj: Clone; -} - -fn clone_projection(p: &T::Proj) -> T::Proj { - p.clone() -} -``` - -```rust,compile_fail,E0277 -#![feature(const_trait_impl)] - -#[const_trait] -trait Trait { - type Proj: ~const Clone; -} - -const fn clone_projection(p: &T::Proj) -> T::Proj { - // error[E0277]: the trait bound `::Proj: ~const Clone` is not satisfied - p.clone() -} -``` - - ### `[tag:impl_block_const_bounds]` The trait bounds of an `impl` block can't include `~const` ```rust,compile_fail diff --git a/src/r3_core/src/bind/sorter.rs b/src/r3_core/src/bind/sorter.rs index 0a085408f9..88eb07cab1 100644 --- a/src/r3_core/src/bind/sorter.rs +++ b/src/r3_core/src/bind/sorter.rs @@ -603,10 +603,6 @@ const fn topological_sort< ) -> bool where Graph: ~const GraphAccess, - // [ref:const_trait_not_implied] necessitates `: ~const MyIterator` - Graph::VertexIter<'a>: ~const MyIterator + ~const Destruct, - // [ref:const_trait_not_implied] necessitates `: ~const MyIterator` - Graph::SuccessorIter<'a>: ~const MyIterator + ~const Destruct, VertexRef: Copy + ~const Destruct, VertexRefLessThan: ~const FnMut(&VertexRef, &VertexRef) -> bool, ReadyVertexQueue: ~const VecLike,