Skip to content

Tracking Issue for early/late bound parameter cleanup and late-bound turbofishing #156581

Description

@addiesh

This is a tracking issue for cleaning up early/late bound lifetimes in the compiler, most notably impacting turbofish syntax (e.g. some_fn::<'static>()). See t-types/#133, as well as the project goal (link missing; wait for the pr).
The feature gate for the issue is #![feature(late_bound_turbofishing)].

Description

In the compiler, function item types are currently represented with TyKind::FnDef, but currently this definition doesn't support late-bound generics.

Currently, using turbofish syntax to provide a specific lifetime for a late-bound lifetime argument on a function does not compile.

// 'a is late bound
fn foo<'a>(b: &'a u32) -> &'a u32 { b }

// error
let f /* : FooFnItem<????> */ = foo::<'static>;

Compare this to early bound arguments, where this does compile (note that 'a: 'a here is just used to coerce the compiler into treating 'a as early bound).

// 'a is early bound.
fn foo<'a: 'a>(b: &'a u32) -> &'a u32 { b }

let f /* : FooFnItem<'static> */ = foo::<'static>;

Our goals with this issue are twofold:

  1. to allow late-bound lifetimes to be specified with turbofish syntax (allowing the first code block to compile), and
  2. generally clean up internal representation WRT differentiating between early & late bound parameters

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Unresolved Questions

  • decide how to deal with semver with the addition of turbofishing functions w/ late-bound params

Implementation history

  1. First steps of late-bound turbofishing (place FnDef behind a dummy binder) #158632

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions