mozcpp: parse a string literal followed by a PRI*/SCN* format macro

Aperta
#1,266 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@marco-c ci sta già lavorando.

Dal 21/11/2026.

  • #1269 di @marco-c — aperta

Valutazione

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

Direzione di ricerca

The failing case is test_fn_id_strings in src/c_langs_macros/mod.rs, currently marked #[ignore]. The grammar change belongs in the tree-sitter-mozcpp dependency, where concatenated_string must accept PRI*/SCN* macros after a string literal. Done means the ignore is removed and the test passes. Pull request #1269 already targets this fix, so check it before starting.

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

Descrizione

Part of #1142 (upstream tree-sitter/tree-sitter-cpp#307).

The C++ grammar only accepts an identifier before a string literal in a concatenated_string, so PRIi32 "%" parses but "%" PRIi32 produces an ERROR node:

nsPrintfCString("%" PRIi32, lifetime.mTag);

This is one of the most common patterns in mozilla-central: the <inttypes.h> format macros (PRIu32, PRIx64, PRId64, ...) are used after a string literal throughout MOZ_LOG, nsPrintfCString, printf_stderr, SprintfLiteral and similar calls. test_fn_id_strings in src/c_langs_macros/mod.rs covers exactly this case and has been #[ignore]d since #1141.

Replacing predefined macros with $ characters (c_macro::replace) doesn't help: "%" $$$$$$ fails the same way. And it's only applied when preprocessor results are available anyway.

Allowing any identifier after a string literal would be ambiguous with things like extern "C" MOZ_EXPORT void f();. A narrower fix in tree-sitter-mozcpp is to accept the <inttypes.h> format macros (PRI*/SCN*) as members of a concatenated_string, and then un-ignore test_fn_id_strings.

Lingua principale
Rust
Stelle
469
Fork
74
Merge medio
17h 16m
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 mozilla/rust-code-analysis

Tutte le issue di mozilla/rust-code-analysis

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.