Skip to content

Add --emit=nothing to tell rustc not to emit any files (even if --crate-type=lib) #52661

Open

Description

In order to only check if a program is well-formed (think cargo check), one would like to call rustc without emitting any files. cargo check uses --emit=metadata -Z no-codegen because the metadata is needed to check dependent crates.

However, it seems like it's impossible to tell the compiler to not write any files in the case of --crate-type=lib. For the default --crate-type=bin it works: rustc -Z no-codegen foo.rs does not emit any files. But again, for rustc -Z no-codegen --crate-type=lib foo.rs it emits an .rlib file.

In case this isn't a bug, would it be possible to add an --emit=nothing or equivalent option?

(Related question on StackOverflow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions