rust/tests
Dylan DPC 8c89601647
Rollup merge of #111494 - compiler-errors:variant-order, r=petrochenkov
Encode `VariantIdx` so we can decode ADT variants in the right order

As far as I can tell, we don't guarantee anything about the ordering of `DefId`s and module children...

The code that motivated this PR (#111483) looks something like:

```rust
#[derive(Protocol)]
pub enum Data {
    #[protocol(discriminator(0x00))]
    Disconnect(Disconnect),
    EncryptionRequest,
    /* more variants... */
}
```

The specific macro ([`protocol`](https://github.com/dylanmckay/protocol)) doesn't really matter, but as far as I can tell (from calls to `build_reduced_graph`), the presence of that `#[protocol(..)]` helper attribute causes the def-id of the `Disconnect` enum variant to be collected *after* its siblings, and it shows up after the other variants in `module_children`.

When we decode the variants for `Data` in a child crate (an example test, in this case), this means that the `Disconnect` variant is moved to the end of the variants list, and all of the other variants now have incorrect relative discriminant data, causing the ICE.

This PR fixes this by sorting manually by variant index after they are decoded. I guess there are alternative ways of fixing this, such as not reusing `module_children_non_reexports` to encode the order-sensitive ADT variants, or to do some sorting in `rustc_resolve`... but none of those seemed particularly satisfying either.

~I really struggled to create a reproduction here -- it required at least 3 crates, one of which is a proc macro, and then some code to actually compute discriminants in the child crate... Needless to say, I failed to repro this in a test, but I can confirm that it fixes the regression in #111483.~ Test exists now.

r? `@petrochenkov` but feel free to reassign. ~Again, sorry for no test, but I hope the explanation at least suggests why a fix like this is likely necessary.~ Feedback is welcome.
2023-05-13 11:05:34 +05:30
..
assembly
auxiliary
codegen Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3 2023-05-11 17:43:07 -07:00
codegen-units
debuginfo
incremental
mir-opt Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegen 2023-05-12 07:11:13 +02:00
pretty
run-make Rollup merge of #111469 - Dushistov:fix-coverage-data-race, r=wesleywiser 2023-05-13 11:05:34 +05:30
run-make-fulldeps
run-pass-valgrind
rustdoc Use proper impl self type for alias impl in rustdoc 2023-05-10 22:49:05 +00:00
rustdoc-gui Convert some GUI tests color checks to use original format 2023-05-11 11:49:16 +02:00
rustdoc-js
rustdoc-js-std
rustdoc-json
rustdoc-ui Fix backtrace normalization in ice-bug-report-url.rs 2023-05-11 13:59:38 +02:00
ui Rollup merge of #111494 - compiler-errors:variant-order, r=petrochenkov 2023-05-13 11:05:34 +05:30
ui-fulldeps Rollup merge of #110747 - oli-obk:smirty, r=spastorino 2023-05-10 06:12:13 +02:00
COMPILER_TESTS.md