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

Abierto
#1,266 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@marco-c ya está trabajando en esto.

Desde el 21/11/2026.

  • #1269 de @marco-c — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
15/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp, rust
Área
devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
469
Forks
74
Merge medio
17 h 16 min
PR fusionados (30 d)
10

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de mozilla/rust-code-analysis

Todos los issues de mozilla/rust-code-analysis

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.