Skip to content

rustdoc: Fix crash when trying to list attributes on an opaque type - #160208

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
GuillaumeGomez:opaque-ty
Jul 31, 2026
Merged

rustdoc: Fix crash when trying to list attributes on an opaque type#160208
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
GuillaumeGomez:opaque-ty

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

Fixes #160107.

It's crashing because we're using get_attrs on an OpaqueTy which cannot have attributes and therefore crashed. So instead, I check ahead of calling this function in the path where this can happen instead of doing it in convert_render_type_id on all RenderTypeId::DefId.

r? @notriddle

@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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 30, 2026
@notriddle

Copy link
Copy Markdown
Contributor

This isn't the real solution. You should be able to search the traits that the opaque type implements. I've pushed a test case to your branch that demonstrates the problem.

Instead, make simplify_fn_type lower the opaque type the same way it already lowers a normal RPIT. convert_render_type_id should never see the DefId of the Opaque type.

@rustbot rustbot added A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-search Area: Rustdoc's search feature labels Jul 31, 2026
@notriddle notriddle closed this Jul 31, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2026
@notriddle

Copy link
Copy Markdown
Contributor

Wait, I'm an idiot. It's working fine. I just wrote the test case wrong.

I've pushed a new test case that actually tests this correctly.

@notriddle notriddle reopened this Jul 31, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2026
@notriddle

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 63d21a9 has been approved by notriddle

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 31, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
rustdoc: Fix crash when trying to list attributes on an opaque type

Fixes rust-lang#160107.

It's crashing because we're using `get_attrs` on an `OpaqueTy` which cannot have attributes and therefore crashed. So instead, I check ahead of calling this function in the path where this can happen instead of doing it in `convert_render_type_id` on all `RenderTypeId::DefId`.

r? @notriddle
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
rustdoc: Fix crash when trying to list attributes on an opaque type

Fixes rust-lang#160107.

It's crashing because we're using `get_attrs` on an `OpaqueTy` which cannot have attributes and therefore crashed. So instead, I check ahead of calling this function in the path where this can happen instead of doing it in `convert_render_type_id` on all `RenderTypeId::DefId`.

r? @notriddle
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
rustdoc: Fix crash when trying to list attributes on an opaque type

Fixes rust-lang#160107.

It's crashing because we're using `get_attrs` on an `OpaqueTy` which cannot have attributes and therefore crashed. So instead, I check ahead of calling this function in the path where this can happen instead of doing it in `convert_render_type_id` on all `RenderTypeId::DefId`.

r? @notriddle
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #160220 (Refactor: shrink region ext traits)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
@rust-bors
rust-bors Bot merged commit ff16970 into rust-lang:main Jul 31, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 31, 2026
rust-timer added a commit that referenced this pull request Jul 31, 2026
Rollup merge of #160208 - GuillaumeGomez:opaque-ty, r=notriddle

rustdoc: Fix crash when trying to list attributes on an opaque type

Fixes #160107.

It's crashing because we're using `get_attrs` on an `OpaqueTy` which cannot have attributes and therefore crashed. So instead, I check ahead of calling this function in the path where this can happen instead of doing it in `convert_render_type_id` on all `RenderTypeId::DefId`.

r? @notriddle
@GuillaumeGomez
GuillaumeGomez deleted the opaque-ty branch July 31, 2026 22:47
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 3, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#160100 (Add "system" option to `override-allocator` directive)
 - rust-lang/rust#160220 (Refactor: shrink region ext traits)
 - rust-lang/rust#159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - rust-lang/rust#159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - rust-lang/rust#160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - rust-lang/rust#160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - rust-lang/rust#154202 (rustfmt: Format `cfg_select!`)
 - rust-lang/rust#159520 (Suggest `Vec<T>` instead of `[T]`)
 - rust-lang/rust#159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts)
 - rust-lang/rust#160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - rust-lang/rust#160066 (rustc_middle: lint attribute cleanups)
 - rust-lang/rust#160085 (Remove various superfluous lint attributes)
 - rust-lang/rust#160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - rust-lang/rust#160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - rust-lang/rust#160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - rust-lang/rust#160157 (Remove outdated comments from `va_list.rs`)
 - rust-lang/rust#160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - rust-lang/rust#160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - rust-lang/rust#160244 (Rename splat to rustc_splat in error messages)
 - rust-lang/rust#160246 (dont fire `unused_mut` on `&pin mut self`)
 - rust-lang/rust#160247 (Configure backport nominations for rustfmt)
 - rust-lang/rust#160274 (renovate: update lock files weekly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-search Area: Rustdoc's search feature 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: When running rustdoc

3 participants