Skip to content

rustfmt and rust-analyzer support for impl_self / impl_scope / impl_anon #57

@dhardy

Description

@dhardy

impl_scope! { ... } and impl_anon! { ... } should be formatted internally just like a module. rustfmt does not currently support this: see rust-lang/rustfmt#5538.

#53 introduced #[impl_self] mod { ... } as a replacement for impl_scope! { ... }. The usage of a fake module appears to have completely solved rustfmt compatibility, but comes with a new problem: rust-analyzer sometimes inserts use ...; statements inside this fake module, leading to macro parse errors.

Possible solutions:

  • Wait for rustfmt to support formatting braced-wrapped macros as a module?
  • Try getting rust-analyzer to ignore the fake module? This seems an unlikely approach; it would require r-a to either have an exception for this macro or expand macros before adding use statements (which may also have issues).
  • Propose an RFC with similar functionality to the above? There have been some related proposals in the past (example).

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