rust-lang / rust-lang/rustc-dev-guide
Example of using rustc_interface to generate the HIR for a file referencing dependent crates?
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.9k
- Forks
- 613
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 39
Description
https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-example.rs is a great example to get me started using rustc_interface, but I am stuck on how to point this query towards a file that references another crate. I want to use rustc to analyze a multi-crate project and build up info across all crates in the project.
I have a repo based directly on rustc-driver-example, showing my problem. See this example which attempts to produce HIR for a file which references another crate. It fails with:
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: failed while formatting fluent string `metadata_cannot_find_crate`:
message was missing
', compiler/rustc_errors/src/emitter.rs:1402:84
However I can generate a HIR for a file that does not depend on other crates.
What do I need to add to the config to make it aware of other crates?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/rustc-driver-example.rs in the rustc-dev-guide and reproduce the failure in the linked megadep repository, especially examples/alphabeta.rs. Trace the rustc_interface configuration used for the single-crate example and compare it with the multi-crate case. Done means documenting or demonstrating the configuration needed to generate HIR when dependent crates are referenced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100