Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

rustfmt can't handle non-UTF-8 input paths

Open Beginner friendly
#7,210 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

The report points to src/bin/main.rs around line 235. Start by tracing how rustfmt reads input paths there and compare that with the reproduction script using a non-UTF-8 filename. Done means rustfmt handles this input without panicking; use the supplied Python script to reproduce the failure and check the result.

Written by the indexing model from the issue text.

Description

A-Unicode C-bug P-low

Summary

The rustfmt command panics when it encounters an input path which is not valid UTF-8. See https://github.com/rust-lang/rust/issues/164585 for the same issue in rustc.

To reproduce the issue, I ran the following python script, which runs rustfmt with a non-UTF-8 input file name:

import shutil
import subprocess

p = subprocess.run([shutil.which("rustfmt"), bytes([255])], check=False)
print(p)

The output I got was:


thread 'main' (204054) panicked at /rustc/58cf8f9c35b355199727627d07ae34a4e2846d67/library/std/src/env.rs:878:51:
called `Result::unwrap()` on an `Err` value: "\xFF"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
CompletedProcess(args=['/opt/homebrew/opt/rustup/bin/rustfmt', b'\xff'], returncode=101)

Probably relevant code: https://github.com/rust-lang/rustfmt/blob/97738dfd687ab9d35338fbceb5def4506c7c4d3b/src/bin/main.rs#L235

Meta

rustfmt --version:

rustfmt 1.10.0-stable (58cf8f9c35 2026-10-13)
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
1d 18h
Merged PRs (30d)
27

Getting set up

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.

More from rust-lang/rustfmt

All issues in rust-lang/rustfmt

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.