Skip to content

Commit

Permalink
refactor(core): associated types can now imply ~const Trait
Browse files Browse the repository at this point in the history
`[ref:const_trait_not_implied]` has been resolved by
[rust-lang/rust#101989][1].

[1]: rust-lang/rust#101989
  • Loading branch information
yvt committed Nov 10, 2022
1 parent f6014cc commit 67972c7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
29 changes: 0 additions & 29 deletions doc/toolchain_limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Trait>(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<T: ~const Trait>(p: &T::Proj) -> T::Proj {
// error[E0277]: the trait bound `<T as Trait>::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
Expand Down
4 changes: 0 additions & 4 deletions src/r3_core/src/bind/sorter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,6 @@ const fn topological_sort<
) -> bool
where
Graph: ~const GraphAccess<VertexRef>,
// [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<Element = VertexRef>,
Expand Down

0 comments on commit 67972c7

Please sign in to comment.