Skip to content

Tail call diagnostics to include lifetime info - #145012

Merged
bors merged 1 commit into
rust-lang:masterfrom
Kivooeo:fun-problem-fun-fix
Aug 15, 2025
Merged

Tail call diagnostics to include lifetime info#145012
bors merged 1 commit into
rust-lang:masterfrom
Kivooeo:fun-problem-fun-fix

Conversation

@Kivooeo

@KivooeoKivooeo commented Aug 6, 2025

Copy link
Copy Markdown
Member

@rustbot

Copy link
Copy Markdown
Collaborator

WaffleLapkin is not on the review rotation at the moment.
They may take a while to respond.

@rustbotrustbot 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 6, 2025
@KivooeoKivooeo changed the title fixed diagnosticTail call diagnostics to include lifetime infoAug 6, 2025
@Kivooeo
Kivooeoforce-pushed the fun-problem-fun-fix branch 2 times, most recently from 9260c5d to 9a9f300CompareAugust 6, 2025 17:07
@rustbotrustbot added the F-explicit_tail_calls `#![feature(explicit_tail_calls)]` label Aug 6, 2025

@compiler-errorscompiler-errors left a comment

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 doesn't fix the issue in the other direction, like:

fn foo(_: fn(&())) {
become bar(dummy);
}
fn bar<'a>(_: fn(&'a ())) {}
fn dummy(_: &()) {}

Comment threadtests/ui/explicit-tail-calls/caller-lifetime-presence.rs Outdated
self.report_arguments_mismatch(expr.span, caller_sig, callee_sig);
self.report_arguments_mismatch(
expr.span,
self.caller_ty.fn_sig(self.tcx).skip_binder(),

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.

Suggested change
self.caller_ty.fn_sig(self.tcx).skip_binder(),
self.caller_ty.fn_sig(self.tcx).instantiate_identity(),

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It does not work for me

error[E0599]: no method named `instantiate_identity` found for struct `Binder` in the current scope
--> compiler/rustc_mir_build/src/check_tail_calls.rs:137:53
|
137 | self.caller_ty.fn_sig(self.tcx).instantiate_identity(),
| ^^^^^^^^^^^^^^^^^^^^ method not found in `Binder<TyCtxt<'_>,FnSig<TyCtxt<'_>>>`

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.

oh, it's a binder, not an early binder. that should be liberated then probably, use tcx.liberate_late_bound_regions instead.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'd love to hear why current approach is not best just to learn things

Also about 'static yes it shows, should I include this in test?

4 | become bar(dummy);
| ^^^^^^^^^^^^^^^^^
|
= note: -Ztrack-diagnostics: created at compiler/rustc_mir_build/src/check_tail_calls.rs:368:14
= note: `become` requires caller and callee to have matching signatures
= note: caller signature: `fn(for<'a> fn(&'a ()))`
= note: callee signature: `fn(fn(&'static ()))`

@KivooeoKivooeoAug 6, 2025

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I did tcx.liberate_late_bound_regions it works but I did not found a better way to obtain DefId rather than do this

Update TailCallCkVisitor with adding a field that will contain def id

structTailCallCkVisitor<'a,'tcx>{
... // existed fieldsdef:DefId,}

And create it like this

letmut visitor = TailCallCkVisitor{
...// eixsted fields
def: def.to_def_id(),};

This might be a bad solution to pass DefId like this?

self.report_arguments_mismatch(
expr.span,self.tcx.liberate_late_bound_regions(self.def,self.caller_ty.fn_sig(self.tcx)),self.tcx.liberate_late_bound_regions(self.def, ty.fn_sig(self.tcx)),);

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Hey @compiler-errors, when you have a moment, could you take another look and let me know which approach you think works better?

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.

It doesn't actually matter what def id you pass. Can you just pass CRATE_DEF_ID for now?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

yeah, CRATE_DEF_ID works, didn't knew about this one

@Kivooeo
Kivooeoforce-pushed the fun-problem-fun-fix branch from 9a9f300 to b2997d5CompareAugust 6, 2025 18:08
@Kivooeo

Kivooeo commented Aug 6, 2025

Copy link
Copy Markdown
MemberAuthor

I fixed other direction, and make test description lesser (not want to shrink it to one liner tho)

If we have a better way to do so, I'm open for suggestions because it's literally first time me opening anything related to tail call

@compiler-errors

Copy link
Copy Markdown
Contributor

You should probably check if this also mentions regions like 'static since those may show up in the signature.

@WaffleLapkin

Copy link
Copy Markdown
Member

r? compiler-errors

@rustbot

Copy link
Copy Markdown
Collaborator

compiler-errors is not on the review rotation at the moment.
They may take a while to respond.

@compiler-errors

Copy link
Copy Markdown
Contributor

@rustbot author

@rustbotrustbot 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 14, 2025
@Kivooeo

Copy link
Copy Markdown
MemberAuthor

Added 'static test and used liberate_late_bound_regions, it looks more verbose but works too, so should be fine @rustbot ready

@rustbotrustbot 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 Aug 14, 2025
@compiler-errors

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented Aug 14, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 51df1da has been approved by compiler-errors

It is now in the queue for this repository.

@borsbors 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 Aug 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
…piler-errors
Tail call diagnostics to include lifetime info
Fixesrust-lang#144957
r? `@WaffleLapkin` `@compiler-errors`
@ZalatharZalathar mentioned this pull request Aug 15, 2025
bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 22 pull requests
Successful merges:
- #118087 (Add Ref/RefMut try_map method)
- #122661 (Change the desugaring of `assert!` for better error output)
- #140740 (Add `-Zindirect-branch-cs-prefix`)
- #142640 (Implement autodiff using intrinsics)
- #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- #144865 (Fix tail calls to `#[track_caller]` functions)
- #144944 (E0793: Clarify that it applies to unions as well)
- #144947 (Fix description of unsigned `checked_exact_div`)
- #145004 (Couple of minor cleanups)
- #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- #145012 (Tail call diagnostics to include lifetime info)
- #145065 (resolve: Introduce `RibKind::Block`)
- #145120 (llvm: Accept new LLVM lifetime format)
- #145189 (Weekly `cargo update`)
- #145235 (Minor `[const]` tweaks)
- #145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
- #145322 (Resolve the prelude import in `build_reduced_graph`)
- #145331 (Make std use the edition 2024 prelude)
- #145369 (Do not ICE on private type in field of unresolved struct)
- #145378 (Add `FnContext` in parser for diagnostic)
- #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
- #145392 (coverage: Remove intermediate data structures from mapping creation)
r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
…piler-errors
Tail call diagnostics to include lifetime info
Fixesrust-lang#144957
r? ``@WaffleLapkin`` ``@compiler-errors``
@ZalatharZalathar mentioned this pull request Aug 15, 2025
bors added a commit that referenced this pull request Aug 15, 2025
Rollup of 21 pull requests
Successful merges:
- #118087 (Add Ref/RefMut try_map method)
- #122661 (Change the desugaring of `assert!` for better error output)
- #142640 (Implement autodiff using intrinsics)
- #143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- #144865 (Fix tail calls to `#[track_caller]` functions)
- #144944 (E0793: Clarify that it applies to unions as well)
- #144947 (Fix description of unsigned `checked_exact_div`)
- #145004 (Couple of minor cleanups)
- #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- #145012 (Tail call diagnostics to include lifetime info)
- #145065 (resolve: Introduce `RibKind::Block`)
- #145120 (llvm: Accept new LLVM lifetime format)
- #145189 (Weekly `cargo update`)
- #145235 (Minor `[const]` tweaks)
- #145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
- #145322 (Resolve the prelude import in `build_reduced_graph`)
- #145331 (Make std use the edition 2024 prelude)
- #145369 (Do not ICE on private type in field of unresolved struct)
- #145378 (Add `FnContext` in parser for diagnostic)
- #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
- #145392 (coverage: Remove intermediate data structures from mapping creation)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 711034f into rust-lang:masterAug 15, 2025
10 checks passed
@rustbotrustbot added this to the 1.91.0 milestone Aug 15, 2025
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145012 - Kivooeo:fun-problem-fun-fix, r=compiler-errors
Tail call diagnostics to include lifetime info
Fixes#144957
r? ```@WaffleLapkin``` ```@compiler-errors```
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
Rollup of 21 pull requests
Successful merges:
- rust-lang/rust#118087 (Add Ref/RefMut try_map method)
- rust-lang/rust#122661 (Change the desugaring of `assert!` for better error output)
- rust-lang/rust#142640 (Implement autodiff using intrinsics)
- rust-lang/rust#143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- rust-lang/rust#144865 (Fix tail calls to `#[track_caller]` functions)
- rust-lang/rust#144944 (E0793: Clarify that it applies to unions as well)
- rust-lang/rust#144947 (Fix description of unsigned `checked_exact_div`)
- rust-lang/rust#145004 (Couple of minor cleanups)
- rust-lang/rust#145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- rust-lang/rust#145012 (Tail call diagnostics to include lifetime info)
- rust-lang/rust#145065 (resolve: Introduce `RibKind::Block`)
- rust-lang/rust#145120 (llvm: Accept new LLVM lifetime format)
- rust-lang/rust#145189 (Weekly `cargo update`)
- rust-lang/rust#145235 (Minor `[const]` tweaks)
- rust-lang/rust#145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
- rust-lang/rust#145322 (Resolve the prelude import in `build_reduced_graph`)
- rust-lang/rust#145331 (Make std use the edition 2024 prelude)
- rust-lang/rust#145369 (Do not ICE on private type in field of unresolved struct)
- rust-lang/rust#145378 (Add `FnContext` in parser for diagnostic)
- rust-lang/rust#145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
- rust-lang/rust#145392 (coverage: Remove intermediate data structures from mapping creation)
r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request Dec 21, 2025
Rollup of 21 pull requests
Successful merges:
- rust-lang/rust#118087 (Add Ref/RefMut try_map method)
- rust-lang/rust#122661 (Change the desugaring of `assert!` for better error output)
- rust-lang/rust#142640 (Implement autodiff using intrinsics)
- rust-lang/rust#143075 (compiler: Allow `extern "interrupt" fn() -> !`)
- rust-lang/rust#144865 (Fix tail calls to `#[track_caller]` functions)
- rust-lang/rust#144944 (E0793: Clarify that it applies to unions as well)
- rust-lang/rust#144947 (Fix description of unsigned `checked_exact_div`)
- rust-lang/rust#145004 (Couple of minor cleanups)
- rust-lang/rust#145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
- rust-lang/rust#145012 (Tail call diagnostics to include lifetime info)
- rust-lang/rust#145065 (resolve: Introduce `RibKind::Block`)
- rust-lang/rust#145120 (llvm: Accept new LLVM lifetime format)
- rust-lang/rust#145189 (Weekly `cargo update`)
- rust-lang/rust#145235 (Minor `[const]` tweaks)
- rust-lang/rust#145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
- rust-lang/rust#145322 (Resolve the prelude import in `build_reduced_graph`)
- rust-lang/rust#145331 (Make std use the edition 2024 prelude)
- rust-lang/rust#145369 (Do not ICE on private type in field of unresolved struct)
- rust-lang/rust#145378 (Add `FnContext` in parser for diagnostic)
- rust-lang/rust#145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
- rust-lang/rust#145392 (coverage: Remove intermediate data structures from mapping creation)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-explicit_tail_calls`#![feature(explicit_tail_calls)]`S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

tail call diagnostics omit lifetimes

5 participants

@Kivooeo@rustbot@compiler-errors@WaffleLapkin@bors