Skip to content

Better error for import of associated items #74030

Open
@ijackson

Description

@ijackson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions