Comment in empty generic arg in macro context is unexpectedly removed

Aperta
#7,182 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #7234 di @compiler-segfault — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
devtools

Direzione di ricerca

Start by running the reproduction in the issue body: rustfmt on a file containing m!(Foo</*c*/>); inside a macro_rules! context should keep the comment, but it is dropped. Check the related fix in #7181, since this issue is a follow-up to it, and trace how rustfmt handles empty generic arguments inside macro invocations. Done means the comment survives formatting in this case and the existing formatter tests still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-comments A-generics A-macros C-bug I-unexpectedly-removes-code

Summary

Follow-up to #7181.

I tried to format this code:

macro_rules! m { ($f:ident </*c*/>) => {} }
fn main() {
    m!(Foo</*c*/>);
}
Expected behavior

I expected to see this happen: keep the comment in the empty generic arg.

Actual behavior

Instead, this happened: comment is removed.

Diff in /Users/joe.xu/Documents/repos/repro/foo.rs:2:
     ($f:ident </*c*/>) => {};
 }
 fn main() {
-    m!(Foo</*c*/>);
+    m!(Foo<>);
 }

Configuration

rustfmt after #7181 applied.

Reproduction Steps

Just run on the file.

Meta

rustfmt after #7181 applied.

Lingua principale
Rust
Stelle
7.1k
Fork
1.2k
Merge medio
1g 4h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rustfmt

Tutte le issue di rust-lang/rustfmt

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.