Skip to content

Recognize Rust function modifier combinations in the spacing helper #890

Open

Description

@LunaStev

Problem

is_function_start uses a short prefix list. Valid pub(crate) const fn functions and other modifier combinations are not detected, leaving adjacent functions unseparated.

Reproduction

Executed the helper at fd07427f4a976de05e38eff3ee1760db97fbb761 using importlib and add_function_spacing on:

pub(crate) const fn first() {}
pub(crate) const fn second() {}

The result is unchanged; the intended separating blank line is missing. Starting point: tools/format-rust.py.

Scope

Recognize legal visibility and const/async/unsafe/extern combinations without treating arbitrary extern blocks or fn text in strings as functions. Difficulty: easy.

Completion criteria

  • Cover combined modifiers and restricted visibility.
  • Keep bodyless declarations and extern blocks distinct.
  • Add a small table-driven Python regression.

Activity

  1. added
    bugA problem that causes incorrect behavior or crashes.
    good first issueIssues that are good for newcomers or first-time contributors.
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA problem that causes incorrect behavior or crashes.good first issueIssues that are good for newcomers or first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions