Skip to content

rustdoc: fix ICE when delegating functions with impl Trait as argument type#156498

Open
cijiugechu wants to merge 1 commit into
rust-lang:mainfrom
cijiugechu:fn_delegation-rustdoc
Open

rustdoc: fix ICE when delegating functions with impl Trait as argument type#156498
cijiugechu wants to merge 1 commit into
rust-lang:mainfrom
cijiugechu:fn_delegation-rustdoc

Conversation

@cijiugechu
Copy link
Copy Markdown
Member

@cijiugechu cijiugechu commented May 12, 2026

HIR signatures for delegation items contain InferDelegation placeholders, clean the inherited fn_sig signature instead.

Closes #155728

@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 May 12, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 12, 2026

r? @lolbinarycat

rustbot has assigned @lolbinarycat.
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: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, camelid, fmease, lolbinarycat, notriddle

@cijiugechu cijiugechu added the F-fn_delegation `#![feature(fn_delegation)]` label May 12, 2026
Copy link
Copy Markdown
Member Author

@cijiugechu cijiugechu May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because delegated signatures now go through tcx.fn_sig, where the inherited bounds may include internal sizedness bounds.

View changes since the review

@lolbinarycat lolbinarycat changed the title rustdoc: fix delegated impl signatures rustdoc: fix ICE when delegating functions with impl Trait as argument type May 12, 2026
#![crate_name = "fn_delegation_impl_trait"]
#![feature(fn_delegation)]
#![allow(incomplete_features)]

Copy link
Copy Markdown
Contributor

@lolbinarycat lolbinarycat May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to also see tests of what happens when delegating to a function defined in a separate crate, since rustdoc won't have the HIR in that case. This can be achieved via the aux-crate directive.

I think using build_function will handle this case correctly, but it would be nice to know for sure/

Also, what happens if we #[doc(inline)] a function that was delegated in a separate crate? What about delegating to a function that was delegated in a separate crate?

There's a lot of possible permutations but I think just adding a few more would make me a lot more confident there's no sneaky edge cases that break.

View changes since the review

@@ -0,0 +1,35 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/155728>
#![crate_name = "fn_delegation_impl_trait"]
Copy link
Copy Markdown
Contributor

@lolbinarycat lolbinarycat May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#![crate_name = "fn_delegation_impl_trait"]

That shouldn't be necessary.

View changes since the review

@@ -0,0 +1,35 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/155728>
Copy link
Copy Markdown
Contributor

@lolbinarycat lolbinarycat May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! Regression test for <https://github.com/rust-lang/rust/issues/155728>
// Regression test for <https://github.com/rust-lang/rust/issues/155728>

nitpick: Usually regular comments are used for test descriptions, not doc comments. Also it would be nice to have a little blurb describing what the test does without having to follow the link, like "Make sure delegating functions with impl Trait in argument position works works correctly."

View changes since the review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-fn_delegation `#![feature(fn_delegation)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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]: rustdoc: assertion failed: cx.impl_trait_bounds.is_empty()

3 participants