Skip to content

Commit 0e73504

Browse files
No where clauses on alias items
1 parent 3933112 commit 0e73504

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

text/3437-implementable-trait-alias.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,10 @@ To resolve these conflicts, you can use trait alias bodies, as described below.
602602

603603
## Bodies for trait aliases
604604

605-
Trait aliases can now optionally contain a body, specifying aliases for various
606-
items. These can be types, constants, or functions.
605+
Trait aliases can now optionally contain a body, which specifies various *alias
606+
items*. These can be types, constants, or functions.
607607

608-
### `type`s and `const` items in trait alias bodies
608+
### `type`s and `const` alias items in trait alias bodies
609609

610610
```rust
611611
trait Foo {
@@ -622,8 +622,8 @@ trait Alias = Foo {
622622
`<T as Alias>::AssocVec` means the same thing as `Vec<<T as Foo>::Assoc>`, and
623623
`<T as Alias>::ASSOC_PLUS_1` is equivalent to `const { <T as Foo>::ASSOC + 1 }`.
624624

625-
Items defined in a trait alias body shadow items of the same name in a primary
626-
trait.
625+
Alias items defined in a trait alias body shadow items of the same name in
626+
primary traits.
627627

628628
```rust
629629
trait Foo {
@@ -640,6 +640,9 @@ trait FooBar = Foo + Bar {
640640
}
641641
```
642642

643+
As aliases, `type` and `const` alias items do not require or accept bounds or
644+
`where` clauses; these are taken from the thing being aliased.
645+
643646
#### Implementability
644647

645648
To be implementable, a `type` or `const` alias item must obey certain
@@ -709,9 +712,9 @@ trait Bar = Foo<Assoc = Result<Self::Foo, Vec<Self::Foo>>> {
709712

710713
#### GATs in type alias bodies
711714

712-
Type alias bodies can also contain GATs. These are also subject to the
713-
implementability rules, though reordering generic parameters does not inhibit
714-
implementability.
715+
Type alias bodies can also contain GAT alias items. These are also subject to
716+
the implementability rules, though reordering generic parameters does not
717+
inhibit implementability.
715718

716719
```rust
717720
trait Foo {
@@ -727,12 +730,15 @@ trait Alias = Foo {
727730
}
728731
```
729732

733+
### Bounds
734+
730735
### `fn`s in type alias bodies
731736

732737
#### Implementable `fn`s
733738

734-
Trait alias bodies can also contain aliases for methods of its primary trait(s).
735-
This involves a new syntax form for implementable function aliases:
739+
Trait alias bodies can also contain function alias items for methods of its
740+
primary trait(s). This involves a new syntax form for implementable function
741+
aliases:
736742

737743
```rust
738744
trait Frob {
@@ -744,7 +750,8 @@ trait Alias = Frob {
744750
}
745751
```
746752

747-
Effect keywords like `const`, `async`, or `unsafe` do not need to be specified.
753+
Effect keywords like `const`, `async`, or `unsafe` do not need to be specified,
754+
and are not permitted.
748755

749756
You are allowed to specify generic parameters, in order to reorder them. But you
750757
don't have to:
@@ -761,6 +768,9 @@ trait Alias = Frob {
761768
}
762769
```
763770

771+
Just like `type` alias items, implementable `fn` alias items neither require nor
772+
accept `where` clauses or bounds of any sort.
773+
764774
#### Non-implementable `fn`s
765775

766776
A trait alias body can also contain non-alias `fn`s, with bodies. These are not
@@ -784,6 +794,10 @@ This is similar to defining an extension trait like
784794
(One difference from extension traits is that trait aliases do not create their
785795
own `dyn` types.)
786796

797+
These non-alias function items can specify `where` clauses and bounds like any
798+
other function item. They also have the same default `Sized` bounds on their
799+
generic type parameters.
800+
787801
## Interaction with `dyn`
788802

789803
Trait aliases do not define their own `dyn` types. This RFC does not change that

0 commit comments

Comments
 (0)