Skip to content

rustfmt nightly panics when trying to format a macro #6632

@klefevre

Description

@klefevre

Hi,

This macro makes rustfmt nightly crash:

macro_rules! impl_routes_and_health {
	($($feature:literal, $variant:ident),* $(,)?) => {
		impl EitherState {
			pub(crate) fn service_name(&self) -> &'static str {
				match self {
					$(
						#[cfg(feature = $feature)]
						Self::$variant(s) => s.service_name(),// BuildService::service_name(s.clone()),
					)*
				}
			}
		}
	};
}

If i remove the trailing comment // BuildService::service_name(s.clone()),, it works as expected.

rustc-ice-2025-08-14T09_52_33-31225.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-macrosbugPanic, non-idempotency, invalid code, etc.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions