Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
fn list_metadata(sess: &Session, metadata_loader: &dyn MetadataLoader) {
match sess.io.input {
Input::File(ref path) => {
if path.extension().is_some_and(|extension| extension == "rs") {
Comment thread
bjorn3 marked this conversation as resolved.
Outdated
let mut err = sess
.dcx()
.struct_fatal("`-Zls` takes a `.rmeta` file as input, not a source file");
if rustc_session::utils::was_invoked_from_cargo() {
// Give a Cargo-tailored suggestion if we're coming from Cargo
err.note("use `rustc +nightly -Zls=... path/to/file.rmeta` directly, instead of going through Cargo");
}
err.emit();
}
let mut v = Vec::new();
locator::list_file_metadata(
&sess.target,
Expand Down
17 changes: 17 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/ls.md
Comment thread
bjorn3 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `ls`

---

Option `-Zls` instructs the compiler to list all metadata from a given metadata file (i.e. files with the `.rmeta` extension).

This allows for debugging the metadata emitted by an earlier compilation.

Note that, while `rustc` usually works with `.rs` files, this option is meant purely for analyzing `.rmeta` files, and does not produce any compilation artifact.

## Example

```sh
rustc +nightly -Zls=all target/debug/deps/libmy_crate-*.rmeta
```

This lists to stdout all metadata from the given `.rmeta` file
Loading