Skip to content

delegation: simplify matches on FnKind, minor refactorings - #160853

Open
aerooneqq wants to merge 3 commits into
rust-lang:mainfrom
aerooneqq:delegation-fn-kind-matches
Open

delegation: simplify matches on FnKind, minor refactorings#160853
aerooneqq wants to merge 3 commits into
rust-lang:mainfrom
aerooneqq:delegation-fn-kind-matches

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR refactors matches on FnKind making them smaller and more concise, next in all matches except fn_kinds function we no longer panic on delegation to inherent impls. And some minor renamings/refactorings. First step for #160505.

Part of #118212.
r? @petrochenkov

@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 Aug 10, 2026
@aerooneqq
aerooneqq force-pushed the delegation-fn-kind-matches branch from 848f238 to 243131e Compare August 10, 2026 12:21
@aerooneqq
aerooneqq force-pushed the delegation-fn-kind-matches branch from e9a04e2 to e680d29 Compare August 12, 2026 07:09
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label Aug 18, 2026
Comment thread compiler/rustc_hir_analysis/src/delegation.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/delegation.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/delegation.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

I'm generally skeptical about introduction of the extension trait.
It would be one thing if it was actually used as a trait (e.g. in bounds), or the methods were somehow "inherent" to TyCtxt.
But doing it just to use the method call syntax? I don't know.

Removing unnecessary lifetime parameters (#160853 (comment)) will make things nicer if the current setup without the extension trait is kept.

@petrochenkov

Copy link
Copy Markdown
Contributor

The logic behind the fn kind matching refactoring is also not very clear to me.
Marking the arms as unreachable is good, merging arms using the same logic like in get_delegation_parent_args_count_without_self is good, making the matches less exhaustive - maybe not so good for readability.

@petrochenkov petrochenkov 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 Aug 18, 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-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.

3 participants