rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

function return type exceeds max width without wrapping

Open jan-ferdinand opened this issue 8 months ago • 1 comments

rustfmt 1.8.0-stable 2025-03-15 4eb161250e does not reformat the following input, violating the default max_width of 100 characters:

mod tests {
    // 100 characters is ··································································· here: |
    fn a_very_long_function_name_such_as_sometimes_found_in_descriptive_test_fn() -> CustomResultType
    {
        todo!()
    }
}

playground

jan-ferdinand avatar Mar 26 '25 10:03 jan-ferdinand

There's some type of Shape issue here. If you add one more character to the function name or to the return type, then it wraps:

mod tests {
    // 100 characters is ··································································· here: |
    fn a_very_long_function_name_such_as_sometimes_found_in_descriptive_test_fnn() -> CustomResultType
    {
        todo!()
    }

    // 100 characters is ··································································· here: |
    fn a_very_long_function_name_such_as_sometimes_found_in_descriptive_test_fn() -> CustomResultTypee
    {
        todo!()
    }
}
mod tests {
    // 100 characters is ··································································· here: |
    fn a_very_long_function_name_such_as_sometimes_found_in_descriptive_test_fnn(
    ) -> CustomResultType {
        todo!()
    }

    // 100 characters is ··································································· here: |
    fn a_very_long_function_name_such_as_sometimes_found_in_descriptive_test_fn(
    ) -> CustomResultTypee {
        todo!()
    }
}

ytmimi avatar Mar 26 '25 13:03 ytmimi