rust-lang / rust-lang/rust

DefaultMetadataLoader was changed to private, making it difficult to print out metadata

Open
#133,510 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Hi,

A recent commit bdacdfe made the DefaultMetadataLoader struct private to the crate.
This makes it impossible to print out the crate metadata using the given functions unless I define my own struct which implements the MetadataLoader trait. I'm currently just trying to understand the metadata file better, and am working with an older version of the Rust compiler so that I can access this type. I'm wondering why this type was made private.

Here is the code I'm using which works with an older version of the compiler:

fn main() {
    let path = std::env::args().nth(1).expect("no path given");
    let path = Path::new(&path);
    let triple = TargetTriple::from_triple("x86_64-apple-darwin");
    let target = Target::expect_builtin(&triple);
    let mut stdout = io::stdout();

    rustc_span::create_session_globals_then(Edition::Edition2018, || {
        let _ = locator::list_file_metadata(&target, path, &DefaultMetadataLoader, &mut stdout);
    });
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing commit bdacdfe and the visibility of DefaultMetadataLoader alongside the MetadataLoader trait and locator::list_file_metadata. Trace how metadata printing is intended to work and check the surrounding compiler tests or API guidance. Done means the supported way to print crate metadata is clear and the visibility or usage path is addressed consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.