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

fn_sig query panicks for specific malformed program. #84569

Closed
crlf0710 opened this issue Apr 26, 2021 · 4 comments
Closed

fn_sig query panicks for specific malformed program. #84569

crlf0710 opened this issue Apr 26, 2021 · 4 comments
Labels
C-bug Category: This is a bug. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.

Comments

@crlf0710
Copy link
Member

During implementation of #84401, i found that fn_sig query panicks for a specific malformed test case:
test/ui/proc-macro/issue-59191-replace-root-with-fn.rs

In #84401 I plan to make the compilation abort after the error is raised, but it would be nice to allow it to continue.

@crlf0710
Copy link
Member Author

Now #84401 is ready to land, let me think more about this.
The current process is this:

  1. rustc_expand properly detected this case, and emitted the error.
  2. However a DefId is still allocated for this malformed structure. But a HirId is never did.
  3. rustc_resolve is able to give this DefId as resolution output, despite it's malformed.
  4. Implement RFC 1260 with feature_name imported_main. #84401 Sent it to fn_sig and other queries
  5. These queries tries to access the hir data with the assumption that every input local def id has corresponding hir data, leading to a index out of range.

It seems i need to break this chain somewhere in the list. Do you have any mentoring advice here, @petrochenkov?

@jyn514
Copy link
Member

jyn514 commented Apr 30, 2021

@crlf0710 I would expect anything with a DefId has a HirId - I would either abort early (before allocating the DefId) or allocate a HirId to go along with it.

@crlf0710
Copy link
Member Author

@jyn514 Thanks! Let me give it a try.

@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@fmease fmease added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. A-proc-macros Area: Procedural macros and removed needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. labels Jan 23, 2024
@Noratrieb Noratrieb removed A-proc-macros Area: Procedural macros A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) labels Feb 21, 2024
@Noratrieb
Copy link
Member

The linked PR was merged and I'm not aware of any bugs, they should be tracked separately anyways.

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.
Projects
None yet
Development

No branches or pull requests

5 participants