Skip to content

Example of using rustc_interface to generate the HIR for a file referencing dependent crates? #1720

Open
@maackle

Description

@maackle

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-custom-driverArea: custom driverC-discussionCategory: discussionE-hardDifficulty: might require advanced knowledgeI-terseIssue: info is very terseT-compilerRelevant to compiler team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions