Offer to close TODO: parse rustflags

Abierto
#333 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
rust
Área
devtools, testing

Línea de trabajo

Lee src/rustflags.rs, especialmente el TODO de las líneas 5 y 13-16, y compáralo con la API propuesta TestCases::with_rustflags. Está hecho cuando trybuild puede pasar flags suministrados explícitamente a la compilación de prueba pertinente sin leer el estado del entorno; el issue no indica ningún archivo de prueba que ejecutar.

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

Descripción

in
https://github.com/dtolnay/trybuild/blob/69689b3ff26787f18592ae9e13035aff619c2310/src/rustflags.rs#L5
you have
https://github.com/dtolnay/trybuild/blob/69689b3ff26787f18592ae9e13035aff619c2310/src/rustflags.rs#L13-L16

I now have a (very specific) use case where additional rustflags are required.

Suggestion & PR offer

I would be happy to offer to draft a PR (manually, not via AI) to offer something like the following API (reading from the env would clearly lead to flaky tests):

#[test]
fn specific_rustflags() {
    let t = trybuild::TestCases::with_rustflags(vec!["-Zallow-features=", "--cfg", "some_cfg"]);
    t.compile_fail("tests/some_cfg/*.rs");
}
Background

My case is the following - I'm sure there will be others who need rustflags for similar or very different reasons:

  • I have a created wrapper around proc_macro::Diagnostic for proc_macro2.
  • I provide a consistent API for all usage, regardless of which channel the final compilation occurs on.
  • I also use additional experimental features (from the try_trait_v2 family) where available.
  • The API is consistent, regardless of which channel is used for the final compilation. I have fall-back to (acceptable, non-breaking & clearly documented) reduced functionality where certain features are not available.
  • I would like to consistently test (not just manually) the outcomes in the following situation:
    • current stable & beta: no diagnostics & no try_trait_v2 ✅ (I can run CI on various toolchains & cfg-gate the path passed to trybuild)
    • current nightly: diagnostics & try_trait_v2 ✅ (I can run CI on various toolchains & cfg-gate the path passed to trybuild)
    • possible future 1: diagnostics but no try_trait_v2 ❌ (can only test manually, I have no way to construct this situation in trybuild)
    • possible future 2: try_trait_v2 but no diagnostics ❌ (can only test manually, I have no way to construct this situation in trybuild)
Lenguaje dominante
Rust
Estrellas
1k
Forks
87
Métricas de merge de PR
Sin PR fusionados en 30 d

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 dtolnay/trybuild

Todos los issues de dtolnay/trybuild

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.