Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic GATs reference information #1265

Merged
merged 11 commits into from
Oct 19, 2022
Prev Previous commit
Next Next commit
Review comments
  • Loading branch information
jackh726 committed Sep 28, 2022
commit 3c8acda52ffcf5f7ca410c76f4fddf0e129592e2
4 changes: 3 additions & 1 deletion src/items/associated-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ lifetime or const parameters, `Bounds` is a plus-separated list of trait bounds
on the associated type, and `WhereBounds` is a comma-separated list of bounds on
parameters:

<!-- ignore: illustrative example forms -->
```rust,ignore
type Assoc;
type Assoc: Bounds;
Expand All @@ -228,11 +229,12 @@ An *associated type definition* defines a type alias for the implementation
of a trait on a type. They are written similarly to an *associated type declaration*,
but cannot contain `Bounds`, but instead must contain a `Type`:

<!-- ignore: illustrative example forms -->
```rust,ignore
type Assoc = Type;
type Assoc<Params> = Type; // the type `Type` here may reference `Params`
type Assoc<Params> where WhereBounds = Type;
type Assoc<Params> = Type where WhereBounds;
type Assoc<Params> where WhereBounds = Type; // deprecated, prefer the form above
```

If a type `Item` has an associated type `Assoc` from a trait `Trait`, then
Expand Down
12 changes: 6 additions & 6 deletions src/items/type-aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ let _ = UseAlias(5); // OK
let _ = TypeAlias(5); // Doesn't work
```

A type alias without the [_Type_] specification may only appear as an
[associated type] in a [trait].
A type alias, when not used as an associated type, must include a [_Type_] and
may not include [_TypeParamBounds_].

A type alias with the [_Type_] specification may only appear as an
[associated type] in a [trait impl].
A type alias, when used as an [associated type] in a [trait], must not include a
[_Type_] specification but may include [_TypeParamBounds_].

A type alias with [_TypeParamBounds_] may only specified when used as
an [associated type] in a [trait].
A type alias, when used as an [associated type] in a [trait impl], must include
a [_Type_] specification and may not include [_TypeParamBounds_].

Where clauses before the equals sign on a type alias in a [trait impl] (like
`type TypeAlias<T> where T: Foo = Bar<T>`) are deprecated. Where clauses after
Expand Down