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 Tune the is_ascii implementation used for short slices 2023-05-06 22:56:43 -07:00
auxiliary
codegen Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3 2023-05-11 17:43:07 -07:00
codegen-units Turn off inlining for codegen-unit tests 2023-04-07 15:46:45 -04:00
debuginfo Rollup merge of #108668 - gibbyfree:stabilizedebuggervisualizer, r=wesleywiser 2023-05-02 11:44:51 +05:30
incremental Add needs-unwind annotations to tests that need stack unwinding 2023-05-02 12:07:55 +00:00
mir-opt Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegen 2023-05-12 07:11:13 +02:00
pretty Rollup merge of #111042 - Zalathar:no-coverage, r=wesleywiser 2023-05-01 17:10:24 +02:00
run-make Rollup merge of #111469 - Dushistov:fix-coverage-data-race, r=wesleywiser 2023-05-13 11:05:34 +05:30
run-make-fulldeps Restrict From<S> for {D,Subd}iagnosticMessage. 2023-05-03 08:44:39 +10:00
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 Rollup merge of #110780 - notriddle:notriddle/slice-index, r=GuillaumeGomez 2023-05-06 09:09:31 +09:00
rustdoc-js-std rustdoc-search: add support for nested generics 2023-04-14 14:55:45 -07:00
rustdoc-json Update tests 2023-04-29 13:01:46 +01:00
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