Skip to content

explicit_tail_calls: cannot become a function that never returns #150243

@nagisa

Description

@nagisa
#![feature(explicit_tail_calls)]

fn foo() -> u64 {
    become std::process::abort()
}

currently says

error[E0308]: mismatched types
 --> src/lib.rs:4:5
  |
4 |     become std::process::abort()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `!`
  |
  = note: expected type `u64`
             found type `!`

While the RFC does require that the types match, ! sounds like it ought to be an exception to this rule: not returning at all is a perfectly valid thing to want to do when tail-calling and should not require any special handling other than in the type checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.F-explicit_tail_calls`#![feature(explicit_tail_calls)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions