Skip to content

Give a better error message when a query isn't supported for a local / external crate #101666

Closed
@jyn514

Description

@jyn514

@richkadel made a great start on this in #83367, but it would be nice to explain the local/external distinction in the panic message; "unsupported by crate" is unhelpful. This is an ICE targeted at compiler developers so IMO it can be pretty much as long as we want.

Currently the error looks like this:

error: internal compiler error: compiler\rustc_middle\src\ty\query.rs:335:1: tcx.module_children(DefId(0:4 ~ similar_paths_reexported[71d7]::module::S)) unsupported by its crate; perhaps the module_children query was never assigned a provider function

I wrote up this description while helping someone debug on discord, which may be a good start:

There are two types of queries. Queries local to the crate, and queries for external crates. This error means that you try to use it for the one that's not supported - usually that's the local crate
But you can tell by looking at CrateId of the DefId

If possible, we should say "tcx.module_children unsupported by local crate" (or external as appropriate, selected at runtime), but if not, we should at least explain what's going wrong better. The link below has a lot of details about the code structure that may be helpful.

Originally posted by @richkadel in #83122 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustA-query-systemArea: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)E-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions