Skip to content

Formatting vis const trait produces invalid code #6619

Description

@boozook

Version: rustfmt 1.8.0-nightly (498ae9fed2 2025-07-28)

Minimal reproducible code:

pub const trait Foo {}

Same for any vis such as pub(crate or in...).

Formatting code above produces invalid code like this:

const pub trait Foo {}

Following is doesn't matter, but my rustfmt.toml config:

reorder_imports = false
reorder_modules = false
reorder_impl_items = false

P.s.: This is a bug, but also

Currently we have three reordering options:

  • reorder_imports
  • reorder_modules
  • reorder_impl_items

I suppose we need new one for things like keywords (vis, effects, etc..).

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions