rust/tests/ui/compiletest-self-test/aux-aux.rs
David Wood a2aa9672f6
compiletest: support auxiliaries with auxiliaries
To test behaviour that depends on the extern options of intermediate
crates, compiletest auxiliaries must have their own auxiliaries.

Auxiliary compilation previously did not trigger compilation of any
auxiliaries in the auxiliary's headers. In addition, those auxiliaries
would need to be in an `auxiliary/auxiliary` directory, which is
unnecessary and makes some crate graphs harder to write tests for,
such as when A depends on B and C, and B depends on C.

For a test `tests/ui/$path/root.rs`, with the following crate graph:

```
root
|-- grandparent
`-- parent
    `-- grandparent
```

then the intermediate outputs from compiletest will be:

```
build/$target/test/ui/$path/
|-- auxiliary
|   |-- libgrandparent.dylib
|   |-- libparent.dylib
|   |-- grandparent
|   |   |-- grandparent.err
|   |   `-- grandparent.out
|   `-- parent
|       |-- parent.err
|       `-- parent.out
|-- libroot.rmeta
|-- root.err
`-- root.out
```

Signed-off-by: David Wood <david@davidtw.co>
2024-02-21 14:37:13 +00:00

15 lines
288 B
Rust

//@ aux-crate: aux_aux_foo=aux_aux_foo.rs
//@ aux-crate: aux_aux_bar=aux_aux_bar.rs
//@ edition: 2021
//@ compile-flags: --crate-type lib
//@ check-pass
use aux_aux_foo::Bar as IndirectBar;
use aux_aux_bar::Bar as DirectBar;
fn foo(x: IndirectBar) {}
fn main() {
foo(DirectBar);
}