Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upClarify public type aliasing behavior #26953
Comments
This comment has been minimized.
This comment has been minimized.
|
These ( In fact, real structure expressions ( |
This comment has been minimized.
This comment has been minimized.
|
What do I know, I just go by what the reference says. |
This comment has been minimized.
This comment has been minimized.
|
Then the reference is wrong – |
This comment has been minimized.
This comment has been minimized.
|
/cc @rust-lang/lang |
steveklabnik
added
the
A-typesystem
label
Jul 16, 2015
This comment has been minimized.
This comment has been minimized.
|
I see why the behavior is confusing, but I see no bug here. The missing ingredient is that Rust has two namespaces, a type and a value namespace. Tuple struct inhabit both, as @arielb1 is saying. When you declare a 'pub use', you are reporting both namespaces simultaneously. When you declare a type alias, though, you are creating a name just in the type namespace, which is why your attempts to use 'A' as a value failed. Niko -------- Original message -------- From: Steve Klabnik notifications@github.com Date:07/16/2015 15:30 (GMT-05:00) To: rust-lang/rust rust@noreply.github.com Cc: Niko Matsakis niko@alum.mit.edu Subject: Re: [rust] Clarify public type aliasing behavior (#26953) — |
This comment has been minimized.
This comment has been minimized.
|
So this is mostly an error message/documentation bug then. |
steveklabnik
added
A-diagnostics
A-docs
and removed
A-typesystem
labels
Mar 8, 2017
This comment has been minimized.
This comment has been minimized.
|
Tagging as docs/diagnostics, in line with the last comment. I'll figure out which of the two it should be at some point, just a quick triage for now. |
This comment has been minimized.
This comment has been minimized.
|
I re-ran all the examples with the latest compiler and updated the error messages (which didn't meaningfully change) |
steveklabnik
added
T-doc
and removed
T-compiler
labels
Mar 9, 2017
steveklabnik
removed
the
A-docs
label
Mar 24, 2017
steveklabnik
added
the
P-medium
label
May 24, 2017
This comment has been minimized.
This comment has been minimized.
|
tagging as p-medium for now; we need to tease apart all of the different stuff that's going on here today |
petrochenkov
added
A-resolve
A-visibility
labels
May 24, 2017
This comment has been minimized.
This comment has been minimized.
|
Current error: // Example #1
rustc 1.19.0-nightly (5b13bff52 2017-05-23)
error[E0423]: expected value, found type alias `A`
--> <anon>:12:11
|
12 | let a=A;
| ^ did you mean `A { /* fields */ }`?
// Example #2
rustc 1.19.0-nightly (5b13bff52 2017-05-23)
error[E0423]: expected value, found type alias `A`
--> <anon>:8:9
|
8 | A
| ^ did you mean `A { /* fields */ }`?
// Example #5
rustc 1.19.0-nightly (5b13bff52 2017-05-23)
error[E0423]: expected function, found type alias `A`
--> <anon>:12:11
|
12 | let a=A(0);
| ^ did you mean `A { /* fields */ }`?So, diagnostics look good enough. |
petrochenkov
removed
A-diagnostics
A-resolve
A-visibility
labels
May 24, 2017
This comment has been minimized.
This comment has been minimized.
|
I'm going to close; if the diagnostics are good, then that's good enough for me. Thanks! |
steveklabnik
closed this
May 26, 2017
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik is the type/value namespace separation discussed in the book? |
jethrogb commentedJul 10, 2015
•
edited
Compile:
Yet A is quite obviously imported. The same error appears in a different place when compiling:
This compiles:
But wait, I thought in example no. 1, we couldn't resolve
Afrommain()?Using
pub useinstead makes example no. 1 work:For completeness, here is the tuple-struct version:
And the regular struct version (compiles without errors):
It seems like structure
expressionsconstructors are handled differently from other uses of types with regards to aliases. Also, the phrasepub typedoes not appear in the Rust Book or the Rust Reference.I propose the following:
expressionsconstructors involving type aliases