rust-lang / rust-lang/rustfmt

`eprintln!` warnings are not (easily) testable

Open
#6,933 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Remark (not for this PR): hm, these eprintln!s feel problematic to me in terms of being able to actually test them. We probably need to not directly use eprintln! and instead use some other custom interceptor which allows promoting warnings -> errors when testing [or such] 🤔

Originally posted by @jieyouxu in https://github.com/rust-lang/rustfmt/pull/6651#discussion_r3323255564

There are a few instances, the one I noticed was

https://github.com/rust-lang/rustfmt/blob/4929253fccb1aaddd3ec2ec240774191b40e9d71/src/config/config_type.rs#L437-L444

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 in src/config/config_type.rs around lines 437-444 and inspect the eprintln! use referenced by the issue. Determine how warnings can be intercepted and promoted during tests; done means the warning behavior is testable without relying on direct eprintln! calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.