rust-lang / rust-lang/rustfmt

Rustfmt eating the colon in bound-less where clause entries (for lifetimes).

Open
#4,637 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

pub fn foo<'a>()
where
    'a: ,
{
}

becomes

pub fn foo<'a>()
where
    'a,
{
}

resulting in syntax error.

This kind of code can actually be usefult to turn 'a into an early bound lifetime.

Tested in the rustfmt shipped with nightly rust (rustfmt 1.4.30-nightly (acd9486 2020-12-20)).

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 running rustfmt on the minimal Rust example in the issue and inspect the formatting path for where-clause lifetime bounds. Add a regression test using the shown input; done means formatting preserves the colon in 'a: , and the result remains valid Rust.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.