rust-lang / rust-lang/rustfmt

Long casts get's moved to a new line

Open
#3,528 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1x-backport:pending I-poor-formatting
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

When running rustfmt on long lines that contains a cast, the formatting gets a bit weird. I copied the code I formatted to a playground that can be found here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4bc27f6604fa0ca8cce228b99e81223c (this wont compile). This is my formatted version, using rustfmt 1.0.3-stable (d6829d6 2019-02-14). I also tried rustfmt 1.2.1-nightly (b860fea 2019-04-18) which seems to be the one at the playground which also results in the same formatting. I think the weird formatting is that as Box<dyn Backend> gets moved to a new line with weird indention.

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

Reproduce the formatting in the linked Rust Playground using the reported stable and nightly rustfmt versions, focusing on the long line containing as Box<dyn Backend>. Trace the rustfmt formatting path responsible for casts and long-line indentation. Done means the cast is formatted without the reported line break and indentation while the example remains correctly formatted.

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.