diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-04-11 13:31:47 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-11 13:31:47 +1000 |
| commit | ea1a31b1501716c60f2f1895e915de8cbca1cff1 (patch) | |
| tree | 0a80886e1c6925aa89a781b9e135cf8936824335 /src/doc/rustc-dev-guide | |
| parent | a7d7a6d0ebbb76d1a43dbff2db208d341873f550 (diff) | |
| parent | c615d1074300f450c435abbf718969bf4f416f98 (diff) | |
| download | rust-ea1a31b1501716c60f2f1895e915de8cbca1cff1.tar.gz rust-ea1a31b1501716c60f2f1895e915de8cbca1cff1.zip | |
Rollup merge of #139469 - jieyouxu:compiletest-supports-crate-type, r=onur-ozkan
Introduce a `//@ needs-crate-type` compiletest directive
The `//@ needs-crate-type: $crate_types...` directive takes a comma-separated list of crate types that the target platform must support in order for the test to be run. This allows the test writer to semantically convey that the ignore condition is based on target crate type needs, instead of using a general purpose `//@ ignore-$target` directive (often without comment).
Fixes #132309.
### Example
```rs
//@ needs-crate-type: dylib (ignored on e.g. wasm32-unknown-unknown)
//@ compile-flags: --crate-type=dylib
fn foo() {}
```
### Review advice
- Best reviewed commit-by-commit.
- The impl is not very clean, I briefly attempted to clean up the directive handling but found that more invasive changes are needed, so I'd like to not block on the cleanup for now.
try-job: test-various
try-job: armhf-gnu
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/tests/directives.md | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md index 8e4a710178e..7ed583c1007 100644 --- a/src/doc/rustc-dev-guide/src/tests/directives.md +++ b/src/doc/rustc-dev-guide/src/tests/directives.md @@ -191,8 +191,13 @@ settings: specified atomic widths, e.g. the test with `//@ needs-target-has-atomic: 8, 16, ptr` will only run if it supports the comma-separated list of atomic widths. -- `needs-dynamic-linking` - ignores if target does not support dynamic linking +- `needs-dynamic-linking` — ignores if target does not support dynamic linking (which is orthogonal to it being unable to create `dylib` and `cdylib` crate types) +- `needs-crate-type` — ignores if target platform does not support one or more + of the comma-delimited list of specified crate types. For example, + `//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored + on `wasm32-unknown-unknown` target because the target does not support the + `proc-macro` crate type. The following directives will check LLVM support: |
