Skip to content

Improve -Zls diagnostic message on .rs files#158859

Merged
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
blyxyas:fix-ls-unstable-opt
Jul 10, 2026
Merged

Improve -Zls diagnostic message on .rs files#158859
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
blyxyas:fix-ls-unstable-opt

Conversation

@blyxyas

@blyxyas blyxyas commented Jul 6, 2026

Copy link
Copy Markdown
Member

View all comments

Refer the user to use rustc -Zls on .rmeta files instead of .rs files. And if they're using cargo, warn them to use rustc directly.

Important

First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on .rmeta files instead of .rs files.

Old description

This unstable option has been broken since forever (more than 2.5 years, at least), but it's exactly what I need for debugging the new incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, src/lib.rs instead of the .rmeta file. So literally every use of -Zls=.. was returning invalid metadata version found: ..

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 6, 2026
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 21 candidates

@rust-log-analyzer

This comment has been minimized.

@blyxyas blyxyas force-pushed the fix-ls-unstable-opt branch from f6dbcdc to dada58c Compare July 6, 2026 14:08
@rust-log-analyzer

This comment has been minimized.

@lqd

lqd commented Jul 6, 2026

Copy link
Copy Markdown
Member

cc @bjorn3 for -Zls expertise

Comment thread tests/ui/rmeta/rmeta-ls.rs Outdated
Comment thread compiler/rustc_driver_impl/src/lib.rs Outdated
Comment thread compiler/rustc_driver_impl/src/lib.rs Outdated
@bjorn3

bjorn3 commented Jul 6, 2026

Copy link
Copy Markdown
Member

rustc +nightly -Zls=all $(rustc +nightly --print target-libdir)/libcore-*.rmeta works just fine for me, while rustc +nightly -Zls=all $(rustc +nightly --print target-libdir)/libcore-*.rlib doesn't. Looks like the issue is that -Zls doesn't support the metadata stub in rlibs that -Zsplit-metadata produces. It should probably just show the CrateHeader and nothing else as that is the only thing the metadata stub contains.

@blyxyas

blyxyas commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Seems that I've misinterpreted how to use the -Zls option. I'll rework the PR to instead output a more meaningful error message.

@blyxyas blyxyas force-pushed the fix-ls-unstable-opt branch from dada58c to 5af51d2 Compare July 6, 2026 17:27
@rust-log-analyzer

This comment has been minimized.

@blyxyas blyxyas force-pushed the fix-ls-unstable-opt branch from 5af51d2 to ae82b10 Compare July 6, 2026 17:34
@blyxyas blyxyas changed the title Fix -Zls unstable opt Improve -Zls diagnostic message on .rs files Jul 6, 2026
@lqd

lqd commented Jul 6, 2026

Copy link
Copy Markdown
Member

It'd be great to also expand the unstable book documentation for -Zls, so other people in the future are not also confused by this option.

@blyxyas

blyxyas commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Done!

Comment thread compiler/rustc_driver_impl/src/lib.rs Outdated
Comment thread src/doc/unstable-book/src/compiler-flags/ls.md
@rust-log-analyzer

This comment has been minimized.

Update unstable book with ls valid values
@rust-cloud-vms rust-cloud-vms Bot force-pushed the fix-ls-unstable-opt branch from 6d521fe to bbba496 Compare July 7, 2026 12:30
Comment thread compiler/rustc_driver_impl/src/lib.rs Outdated
Comment thread src/doc/unstable-book/src/compiler-flags/ls.md Outdated
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 9, 2026
Comment thread compiler/rustc_metadata/src/locator.rs Outdated
@bjorn3

bjorn3 commented Jul 9, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ab8da78 has been approved by bjorn3

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
Improve `-Zls` diagnostic message on `.rs` files

Refer the user to use `rustc -Zls` on `.rmeta` files instead of `.rs` files. And if they're using cargo, warn them to use rustc directly.

> [!IMPORTANT]
> First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on `.rmeta` files instead of `.rs` files.

<details><summary>Old description</summary>
<p>
This unstable option has been broken since forever (more than 2.5 years,
at least), but it's exactly what I need for debugging the new
incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, `src/lib.rs` instead of the `.rmeta` file. So literally every use of `-Zls=..` was returning  `invalid metadata version found: ..`

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

</p>
</details>
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
Improve `-Zls` diagnostic message on `.rs` files

Refer the user to use `rustc -Zls` on `.rmeta` files instead of `.rs` files. And if they're using cargo, warn them to use rustc directly.

> [!IMPORTANT]
> First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on `.rmeta` files instead of `.rs` files.

<details><summary>Old description</summary>
<p>
This unstable option has been broken since forever (more than 2.5 years,
at least), but it's exactly what I need for debugging the new
incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, `src/lib.rs` instead of the `.rmeta` file. So literally every use of `-Zls=..` was returning  `invalid metadata version found: ..`

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

</p>
</details>
@fee1-dead fee1-dead assigned bjorn3 and unassigned fee1-dead Jul 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
Improve `-Zls` diagnostic message on `.rs` files

Refer the user to use `rustc -Zls` on `.rmeta` files instead of `.rs` files. And if they're using cargo, warn them to use rustc directly.

> [!IMPORTANT]
> First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on `.rmeta` files instead of `.rs` files.

<details><summary>Old description</summary>
<p>
This unstable option has been broken since forever (more than 2.5 years,
at least), but it's exactly what I need for debugging the new
incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, `src/lib.rs` instead of the `.rmeta` file. So literally every use of `-Zls=..` was returning  `invalid metadata version found: ..`

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

</p>
</details>
rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
 - #156027 (Consider captured regions for opaque type region liveness.)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #157561 (rustdoc: do not include extra stuff in span)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158995 (Use REST API in linkchecker script)
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 9, 2026
Improve `-Zls` diagnostic message on `.rs` files

Refer the user to use `rustc -Zls` on `.rmeta` files instead of `.rs` files. And if they're using cargo, warn them to use rustc directly.

> [!IMPORTANT]
> First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on `.rmeta` files instead of `.rs` files.

<details><summary>Old description</summary>
<p>
This unstable option has been broken since forever (more than 2.5 years,
at least), but it's exactly what I need for debugging the new
incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, `src/lib.rs` instead of the `.rmeta` file. So literally every use of `-Zls=..` was returning  `invalid metadata version found: ..`

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

</p>
</details>
rust-bors Bot pushed a commit that referenced this pull request Jul 10, 2026
Rollup of 24 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #156027 (Consider captured regions for opaque type region liveness.)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #157561 (rustdoc: do not include extra stuff in span)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158960 (Fix bootstrap submodule path prefix matching)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158995 (Use REST API in linkchecker script)
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
 - #159036 (bootstrap: expand '@argfile' arguments to rustc shim)
@rust-bors rust-bors Bot merged commit 1ae52bc into rust-lang:main Jul 10, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 10, 2026
rust-timer added a commit that referenced this pull request Jul 10, 2026
Rollup merge of #158859 - blyxyas:fix-ls-unstable-opt, r=bjorn3

Improve `-Zls` diagnostic message on `.rs` files

Refer the user to use `rustc -Zls` on `.rmeta` files instead of `.rs` files. And if they're using cargo, warn them to use rustc directly.

> [!IMPORTANT]
> First few comments in this pull request refer to changing the flag itself to work on source files. This was instead overruled to warn the user about executing on `.rmeta` files instead of `.rs` files.

<details><summary>Old description</summary>
<p>
This unstable option has been broken since forever (more than 2.5 years,
at least), but it's exactly what I need for debugging the new
incremental system, so rather than removing it I opted for fixing it.

The issue was that we were feeding the source file like, `src/lib.rs` instead of the `.rmeta` file. So literally every use of `-Zls=..` was returning  `invalid metadata version found: ..`

This PR also includes some testing.

Relevant for rust-lang/rust-project-goals#641.

</p>
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants