rust-lang / rust-lang/rust

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

Open
#156,581 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-type-system C-tracking-issue T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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. https://github.com/rust-lang/rust/pull/158632
  2. #159403

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked implementation history and the feature gate late_bound_turbofishing, then inspect the listed type definitions: ty::Generics, GenericParamDef/GenericParamDefKind, and TyKind::FnDef. Trace the generics_of query and the remaining checklist items. Done means the early/late-bound representation is updated, documentation and syntax style work are addressed, and stabilization requirements are met.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.