Offer to close TODO: parse rustflags
- Dominant language
- Rust
- Stars
- 998
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
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):
```rust
#[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)
Contributor guide
No contributing guide indexed for this repository
Research direction
Read src/rustflags.rs, especially the TODO at lines 5 and 13-16, and compare it with the proposed TestCases::with_rustflags API. Done means trybuild can pass explicitly supplied flags to the relevant test compilation without reading environment state; the issue does not name a test file to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100