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

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

Open
Ramla-I opened this issue Nov 26, 2024 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Ramla-I
Copy link

Ramla-I commented Nov 26, 2024

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);
    });
}
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 26, 2024
@workingjubilee
Copy link
Member

workingjubilee commented Nov 27, 2024

Because having types be publicly accessible when they do not need to be is not ideal, as none of these constitute a stable API. But as this issue demonstrates, sometimes people try to depend on them anyways.

"It's not stable API" remarks aside, please feel free to submit a PR making an API public again with a note about why. This will allow us to check on the noted reason and determine if it is still relevant if we decide to make it private once more. It likely won't stop us from breaking it, in the end, but it might at least give you a heads up and probably make it so that the next time we break it isn't "literally next week".

@workingjubilee workingjubilee added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants