-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustA-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)A-query-systemArea: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This is mostly just a rustc developer experience issue that crops up if you accidentally introduce a query cycle before ast lowering completes. After this happened to me a few times, I finally understand what is happening so I figured I should document it.
If a query cycle occurs before or during ast lowering, then rustc winds up querying for the HIR while trying to collect info about the cycle to report it, and this leads to another cycle and more panics, which is rather confusing to behold. The root issue is that we try to call the def_span
and def_kind
queries in the following places:
Some(key.default_span(*tcx)) |
(default_span
is implemented using def_span
if the key is DefId
or LocalDefId
)
def_id.and_then(|def_id| def_id.as_local()).and_then(|def_id| tcx.opt_def_kind(def_id)) |
Some ideas:
- Use
source_span
instead ofdef_span
- Add a way to get
def_span
and/ordef_kind
from AST (probably only for diagnostics cases like this) - Add a way to detect if AST has been lowered, and skip those queries if not
Metadata
Metadata
Assignees
Labels
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustA-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)A-query-systemArea: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: 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.Relevant to the compiler team, which will review and decide on the PR/issue.