Skip to content

We shouldn't be able to tail-call #[track_caller] functions #145321

@compiler-errors

Description

@compiler-errors

I tried this code:

struct Struct;

fn foo<T: ?Sized>(t: &T) -> usize {
    become bar(t);
}

#[track_caller]
fn bar<T: ?Sized>(_: &T) -> usize {
    456
}

fn main() {
    assert_eq!(foo(&Struct), 456);
}

I expected to see: Not sure actually.

Instead, LLVM's opt --passes=verify fails b/c we're performing a tail call with an incompatible signature.

Meta

rustc --version --verbose:

whatever is nightly on august 12, 2025

Not really an ICE per se, but a llvm bug. It doesn't show up on nightly b/c llvm is not built with debug assertions, I think, but it does show up when you pass the generated llvm to opt. I did this in alive2.

I think we need to rework how tail calls handle both pre-mono and post-mono #[track_caller] :3

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-explicit_tail_calls`#![feature(explicit_tail_calls)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions