From 6d54054c520822cac8033a05a2c5cf824b626a63 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 9 Jun 2020 16:15:06 -0700 Subject: [PATCH 1/4] fix out of date info on type aliases --- src/items/type-aliases.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/items/type-aliases.md b/src/items/type-aliases.md index b811a937b..3c6c9dce5 100644 --- a/src/items/type-aliases.md +++ b/src/items/type-aliases.md @@ -20,13 +20,18 @@ type Point = (u8, u8); let p: Point = (41, 68); ``` -A type alias to an enum type cannot be used to qualify the constructors: +A type alias to an tuple-struct type cannot be used to qualify the constructors: ```rust -enum E { A } -type F = E; -let _: F = E::A; // OK -// let _: F = F::A; // Doesn't work +pub struct MyStruct(u32); + +pub use self::MyStruct as PubUse; +pub type PubType = MyStruct; + +fn main() { + let _ = PubUse(5); // OK + // let _ = PubType(5); // Doesn't work +} ``` [IDENTIFIER]: ../identifiers.md From 1d42f56da37c2d7edf694ee542d1c040c3a77490 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 9 Jun 2020 17:03:38 -0700 Subject: [PATCH 2/4] fix based on review --- src/items/type-aliases.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/items/type-aliases.md b/src/items/type-aliases.md index 3c6c9dce5..40c7c7145 100644 --- a/src/items/type-aliases.md +++ b/src/items/type-aliases.md @@ -20,9 +20,9 @@ type Point = (u8, u8); let p: Point = (41, 68); ``` -A type alias to an tuple-struct type cannot be used to qualify the constructors: +A type alias to a tuple-struct or unit-struct cannot be used to qualify that type's constructor: -```rust +```rust,edition2018,compile_fail pub struct MyStruct(u32); pub use self::MyStruct as PubUse; @@ -30,7 +30,7 @@ pub type PubType = MyStruct; fn main() { let _ = PubUse(5); // OK - // let _ = PubType(5); // Doesn't work + let _ = PubType(5); // Doesn't work } ``` From 0564cc937502e5b84ebe1dbd0eeb91a265425c3d Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 9 Jun 2020 17:43:43 -0700 Subject: [PATCH 3/4] remove pub --- src/items/type-aliases.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/items/type-aliases.md b/src/items/type-aliases.md index 40c7c7145..6f43f2dff 100644 --- a/src/items/type-aliases.md +++ b/src/items/type-aliases.md @@ -23,15 +23,13 @@ let p: Point = (41, 68); A type alias to a tuple-struct or unit-struct cannot be used to qualify that type's constructor: ```rust,edition2018,compile_fail -pub struct MyStruct(u32); +struct MyStruct(u32); -pub use self::MyStruct as PubUse; -pub type PubType = MyStruct; +use self::MyStruct as PubUse; +type PubType = MyStruct; -fn main() { - let _ = PubUse(5); // OK - let _ = PubType(5); // Doesn't work -} +let _ = PubUse(5); // OK +let _ = PubType(5); // Doesn't work ``` [IDENTIFIER]: ../identifiers.md From d150e88973ffccc4439111d8e1b26da745670fa8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 Jun 2020 11:47:30 -0700 Subject: [PATCH 4/4] Rename examples to not use "pub". --- src/items/type-aliases.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/items/type-aliases.md b/src/items/type-aliases.md index 6f43f2dff..6afd7a7fa 100644 --- a/src/items/type-aliases.md +++ b/src/items/type-aliases.md @@ -25,11 +25,11 @@ A type alias to a tuple-struct or unit-struct cannot be used to qualify that typ ```rust,edition2018,compile_fail struct MyStruct(u32); -use self::MyStruct as PubUse; -type PubType = MyStruct; +use MyStruct as UseAlias; +type TypeAlias = MyStruct; -let _ = PubUse(5); // OK -let _ = PubType(5); // Doesn't work +let _ = UseAlias(5); // OK +let _ = TypeAlias(5); // Doesn't work ``` [IDENTIFIER]: ../identifiers.md