Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/items/type-aliases.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@

# Type aliases

> **<sup>Syntax</sup>**\
Expand DownExpand Up@@ -33,10 +34,30 @@ 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 to an enum cannot refer to the enum's variants within a [use declaration]:

```rust,edition2018,compile_fail,E0432
mod my_mod {
pub enum MyEnum {
MyVariant
}

pub type TypeAlias = MyEnum;
}

use my_mod::MyEnum; // OK
use my_mod::MyEnum::MyVariant; // OK
use my_mod::TypeAlias; // OK
use my_mod::TypeAlias::MyVariant; // Doesn't work

let _ = my_mod::TypeAlias::MyVariant; // OK
```

[IDENTIFIER]: ../identifiers.md
[_GenericParams_]: generics.md
[_WhereClause_]: generics.md#where-clauses
[_Type_]: ../types.md#type-expressions
[associated type]: associated-items.md#associated-types
[trait]: traits.md
[type]: ../types.md
[use declaration]: use-declarations.md