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

Better error for import of associated items #74030

Open
ijackson opened this issue Jul 4, 2020 · 1 comment
Open

Better error for import of associated items #74030

ijackson opened this issue Jul 4, 2020 · 1 comment
Labels
A-associated-items Area: Associated items such as associated types and consts. A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ijackson
Copy link
Contributor

ijackson commented Jul 4, 2020

Hi. I was using a crate which had a struct with a number of associated items and I was trying to save typing in an error handling function. But:

12 |     use rocket::http::Status::*;
   |                       ^^^^^^ `Status` is a struct, not a module

I looked in the Reference and I wasn't able to find any discussion of this. In particular, I would expect it to be documented in the explanation of Use declarations under Items.

After considerably more digging, I found:

It seems that this situation is likely to persist. Maybe the error message could be improved? Something like

hint: importing associated items is not supported; you must use a path from to the parent type each time

could help the user by letting them know they can't avoid the extra typing.

I will also file an issue against the Reference. Thanks for your attention.

@ijackson ijackson added the C-bug Category: This is a bug. label Jul 4, 2020
@ijackson ijackson changed the title Better error fo import of associated items, is not documented Better error for import of associated items Jul 4, 2020
@ijackson
Copy link
Contributor Author

ijackson commented Jul 4, 2020

Sorry, but I can't see how to remove the bug tag. (This issue was originally going to be my bug report against the reference and somehow I accidentally submitted it while it was still half-finished.) Could someone fix that for me ?

@jonas-schievink jonas-schievink added A-associated-items Area: Associated items such as associated types and consts. A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants