Skip to content

Commented function parameter causes wrapping which breaks function declaration #6825

@illicitonion

Description

@illicitonion

Summary

I tried to format this code:

pub async fn foo(
    // OriginalUri(original_uri): OriginalUri,
) -> Option<Option<Option<Option<String>>>> {
    None
}

Expected behavior

I expected the code to continue to successfully compile after rustfmt.

Actual behavior

It gets reformatted to:

pub async fn foo(// OriginalUri(original_uri): OriginalUri,)
 -> Option<Option<Option<Option<String>>>> {
    None
}

where the closing ) ends up being commented out.

This only happens if both the comment and the return type are sufficiently long/complex.

Configuration

$ rustfmt +nightly --edition 2024 src/lib.rs

Meta

rustfmt --version:

rustfmt 1.9.0-nightly (0c68443b0a 2026-03-10)

Metadata

Metadata

Assignees

Labels

A-2024-style-editionArea: style edition 2024A-commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-invalid-codeIssue: formatting causes compile-pass code to compile-failS-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions