Skip to content

Next steps for FnDef binder changes (instantiate most FnDef binders)#159403

Open
addiesh wants to merge 3 commits into
rust-lang:mainfrom
addiesh:call-me-turbofishmael
Open

Next steps for FnDef binder changes (instantiate most FnDef binders)#159403
addiesh wants to merge 3 commits into
rust-lang:mainfrom
addiesh:call-me-turbofishmael

Conversation

@addiesh

@addiesh addiesh commented Jul 16, 2026

Copy link
Copy Markdown

View all comments

This change is a part of the ongoing effort to clean up binder/turbofishing behavior in the compiler (#156581).

This PR instantiates binders that were previously created via ty::Binder::dummy() with meaningfully bound vars.

r? oli-obk

Call me Turbofishmael.
Some years ago- never mind how long precisely-
having little or no money in my purse,
and nothing particular to interest me in C++,
I thought I would sail about a little and see the rusty part of the world.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 16, 2026
@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @oli-obk (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@addiesh
addiesh force-pushed the call-me-turbofishmael branch 3 times, most recently from 014b214 to d780036 Compare July 16, 2026 19:40
@rust-log-analyzer

This comment has been minimized.

@addiesh

addiesh commented Jul 16, 2026

Copy link
Copy Markdown
Author

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)

what happened during the rebase??? lemme rollback and try see what broke

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from d780036 to 6e740ba Compare July 16, 2026 20:10
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 330681e to 83e428c Compare July 17, 2026 15:14
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 9fb9767 to 3920a9e Compare July 17, 2026 22:34
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 5373d53 to f118249 Compare July 20, 2026 15:15
@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from f118249 to 6aeb29e Compare July 20, 2026 15:28
@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 6aeb29e to ac8e8e5 Compare July 20, 2026 15:33
@addiesh
addiesh marked this pull request as ready for review July 20, 2026 15:48
Comment on lines +68 to +75
TraitItemKind::Fn(_, _) => Ty::new_fn_def(
tcx,
def_id.to_def_id(),
ty::Binder::bind_with_vars(
ty::GenericArgs::identity_for_item(tcx, def_id),
tcx.late_bound_vars(item.hir_id()),
),
),

@oli-obk oli-obk Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

preexisting, but considering how duplicated this is across the various invocations, add a a closure above for creating such a fn def and just invoke it in each site.

View changes since the review

let args = ty::GenericArgs::identity_for_item(tcx, def_id);
// FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes)
Ty::new_fn_def(tcx, ctor.to_def_id(), ty::Binder::dummy(args))
let fn_sig = tcx.fn_sig(ctor.to_def_id()).instantiate_identity().skip_norm_wip();

@oli-obk oli-obk Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is still going through fn_sig, take the late_bound_vars route here (and everywhere below), too

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you'll probably want to add a late_bound_vars_for_def_id that internally just invokes local_def_id_to_hir_id and then uses that HirId for late_bound_vars.

Ok(a_ty)
}

fn relate_ty_args_bound(

@oli-obk oli-obk Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how much is relate_ty_args used? Could we just have a single function, or if that's too verbose, implement relate_ty_args in the trait with a default impl that calls relate_ty_args_bound and remove all impl overrides of relate_ty_args?

View changes since the review

}

pub fn combine_ty_args_bound<Infcx, I, R>(
infcx: &Infcx,

@oli-obk oli-obk Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same thing here, avoid this duplication, maybe just by implementing combine_ty_args in terms of combine_ty_args_bound, but ideally just by having bound vars on combine_ty_args and adjusting all the call sites (if it's not too many). If the latter is reasonably doable, then do it in a separate commit before all the other commits in this PR

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 Jul 20, 2026
@rustbot

rustbot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 92a8cca to bdb055e Compare July 20, 2026 17:49
@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from bdb055e to 60bc61a Compare July 20, 2026 17:56
@addiesh

addiesh commented Jul 20, 2026

Copy link
Copy Markdown
Author

@rustbot ready :3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 20, 2026
@oli-obk

oli-obk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 21, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
Next steps for FnDef binder changes (instantiate most FnDef binders)
@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: b2c0bf0 (b2c0bf0eafe2c8ec02d1dc04054ef086c27e56a4)
Base parent: f65b272 (f65b272fc92b1e7527dea4a224430a249ab25c2d)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b2c0bf0): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.4%] 16
Regressions ❌
(secondary)
0.3% [0.1%, 0.7%] 12
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) 0.3% [-0.2%, 0.4%] 17

Max RSS (memory usage)

Results (primary 0.9%, secondary -4.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.9% [0.6%, 1.1%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.4% [-4.4%, -4.4%] 1
All ❌✅ (primary) 0.9% [0.6%, 1.1%] 5

Cycles

Results (primary 2.3%, secondary 3.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
3.7% [3.1%, 4.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.3% [2.3%, 2.3%] 1

Binary size

Results (primary 0.2%, secondary 0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.5%] 77
Regressions ❌
(secondary)
0.3% [0.0%, 1.0%] 64
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.0%, 0.5%] 77

Bootstrap: 487.415s -> 488.409s (0.20%)
Artifact size: 387.80 MiB -> 388.33 MiB (0.14%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 21, 2026
@rust-log-analyzer

This comment has been minimized.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 4b6280c to 1d38675 Compare July 23, 2026 08:48
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@addiesh
addiesh force-pushed the call-me-turbofishmael branch from 1d38675 to a5f0deb Compare July 23, 2026 08:53
@rust-bors

rust-bors Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159942) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. perf-regression Performance regression. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants