Skip to content

rustdoc: don't panic on a nested use group with no path prefix - #164883

Open
sreekaransrinath wants to merge 2 commits into
rust-lang:mainfrom
sreekaransrinath:rustdoc-empty-nested-use
Open

sreekaransrinath wants to merge 2 commits into
rust-lang:mainfrom
sreekaransrinath:rustdoc-empty-nested-use

Conversation

@sreekaransrinath

@sreekaransrinath sreekaransrinath commented Oct 25, 2026 •

Copy link
Copy Markdown

fixes #164158

rustdoc panicked on a nested use group with no path in front of it, like use {{}}; or use {a, {b}};, because clean_use_statement called unwrap() on the last segment of a path that had no segments.

we now check the last segment with is_some_and instead, so the self handling only runs when there's a segment to look at

the new test covers use {{}}; and the nested shape from the crater run. i ran it locally and it panics at the same line without the fix and passes with it

this is a stable-to-beta regression though, so it may be worth a beta backport

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

rustbot commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @GuillaumeGomez (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, camelid, lolbinarycat, notriddle

@theemathas theemathas added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 25, 2026
@theemathas

Copy link
Copy Markdown
Contributor

Please also test the following in edition 2015:

mod what {
    use {*};
}

@GuillaumeGomez

Copy link
Copy Markdown
Member

Please add the test as mentioned by @theemathas but otherwise looks good to me.

sreekaransrinath added a commit to sreekaransrinath/rust that referenced this pull request Oct 25, 2026
Cover `mod { use {*}; }` in edition 2015 as requested in rust-lang#164883 review.
@rustbot

This comment has been minimized.

Cover `mod { use {*}; }` in edition 2015 as requested in review.
@sreekaransrinath
sreekaransrinath force-pushed the rustdoc-empty-nested-use branch from ccc2b06 to 71f85a5 Compare October 25, 2026 16:30
@sreekaransrinath

Copy link
Copy Markdown
Author

added! ty @theemathas @GuillaumeGomez

@GuillaumeGomez

Copy link
Copy Markdown
Member

Thanks!

@bors r=theemathas,GuillaumeGomez

@rust-bors

rust-bors Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 71f85a5 has been tentatively approved by theemathas,GuillaumeGomez

It will be put into the queue for this repository once PR CI succeeds.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: test-aarch64-apple-macos-26-2 out of disk space

@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 Oct 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 25, 2026
…ted-use, r=theemathas,GuillaumeGomez

rustdoc: don't panic on a nested use group with no path prefix

fixes rust-lang#164158

rustdoc panicked on a nested use group with no path in front of it, like `use {{}};` or `use {a, {b}};`, because `clean_use_statement` called `unwrap()` on the last segment of a path that had no segments.

we now check  the last segment with `is_some_and` instead, so the `self` handling only runs when there's a segment to look at

the new test covers `use {{}};` and the nested shape from the crater run. i ran it locally and it panics at the same line without the fix and passes with it

this is a stable-to-beta regression though, so it may be worth a beta backport
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 25, 2026
…ted-use, r=theemathas,GuillaumeGomez

rustdoc: don't panic on a nested use group with no path prefix

fixes rust-lang#164158

rustdoc panicked on a nested use group with no path in front of it, like `use {{}};` or `use {a, {b}};`, because `clean_use_statement` called `unwrap()` on the last segment of a path that had no segments.

we now check  the last segment with `is_some_and` instead, so the `self` handling only runs when there's a segment to look at

the new test covers `use {{}};` and the nested shape from the crater run. i ran it locally and it panics at the same line without the fix and passes with it

this is a stable-to-beta regression though, so it may be worth a beta backport
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 25, 2026
…ted-use, r=theemathas,GuillaumeGomez

rustdoc: don't panic on a nested use group with no path prefix

fixes rust-lang#164158

rustdoc panicked on a nested use group with no path in front of it, like `use {{}};` or `use {a, {b}};`, because `clean_use_statement` called `unwrap()` on the last segment of a path that had no segments.

we now check  the last segment with `is_some_and` instead, so the `self` handling only runs when there's a segment to look at

the new test covers `use {{}};` and the nested shape from the crater run. i ran it locally and it panics at the same line without the fix and passes with it

this is a stable-to-beta regression though, so it may be worth a beta backport

This branch has not been deployed

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

Labels

beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.100 beta rustdoc crater regression: "called Option::unwrap() on a None value" in librustdoc/clean/mod.rs

4 participants