-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Cannot call static methods on type aliases, "module wasn't actually a module!" #11047
Comments
#4508 seems related. |
The problem here is calling a static method through a typedef. The error messages getting printed is another unrelated bug (but easy to fix). To the best of my knowledge, this has never worked, and I was under the impression that was intentional. @pcwalton, is it intended to be able to call methods through a typedef? |
I've noticed this issue as well. It's definitely inconvenient that this doesn't work. Also, it took me a while to realise the error message was complete rubbish. |
Exhibit A:
This badly needs a typedef - Queue is not descriptive enough, but |
cc me |
This now prints sane error messages:
|
I accidentally triggered this and indeed the diagnosis is better. Unfortunately, it also means that aliases are second-class citizens and seriously hampers their usefulness... |
@huonw That doesn't really seem like a reasonable error message to me. Coming from other languages where there's something like functions in a type, that types sort of incidentally also create a module of the same name into which subsequent (Also surprised that #3884 wasn't linked in here yet.) |
@ben0x539 I meant to say saner error messages, since it no longer has the "lexical" error junk. |
I keep bumping into #19130 and this issue, and keep referring to the docs assuming it's a mistake. It would seem that one of the most common reasons to use a type alias would be for generics, however due to this issue, the The official docs on type alias only show an example of a tuple type alias, and no mention is made of traits or generic types. The Rust by Example docs on type alias only alias ordinal types, but it does mention aliasing generic types in passing at the end. It seems very natural to want to write:
but you get the rather ambiguous error:
when the type declaration is right there, and then have to write this instead, which rather defeats the purpose:
Anyway, I guess this is a big +1 for this issue. |
@pcwalton, @alexcrichton, @pnkfelix : Was this bug ever triaged? I think this should be considered for 1.0 nomination. |
I'll renominate to make sure we see this. My personal recommendation though is that if the only bug is generating more errors than we should then this isn't a 1.0 issue. |
This is a nice-to-have, not a 1.0 blocker. Marking as P-high. |
I would agree that type aliases are pretty useless when you can't use them as first class types. If I can do |
@LukasKalbertodt I believe we all agree on this; however 1.0 does not mean "finished" but "backward compatible" and calling static methods on type aliases is not necessary for backward compatibility since all programs without will continue to compile once it is implemented (the converse would not be true). Therefore, while I personally value this improvement, I understand that it is not necessary for 1.0. |
This seems to work on 1.3+. |
Verified this works on 1.3. I created a test for this issue. https://github.com/rust-lang/rust/pull/28703/files |
Tests invoking a static method using a type alias. Closes #11047
Compile this:
I can't imagine that this is intentional, as it greatly limits the utility of type aliases.
The text was updated successfully, but these errors were encountered: