rust/tests
Matthias Krüger a88354831b
Rollup merge of - compiler-errors:supertrait-assoc-ty-unsoundness, r=lcnr
Fix supertrait associated type unsoundness

### What?

Object safety allows us to name `Self::Assoc` associated types in certain positions if they come from our trait or one of our supertraits. When this check was implemented, I think it failed to consider that supertraits can have different args, and it was only checking def-id equality.

This is problematic, since we can sneak different implementations in by implementing `Supertrait<NotActuallyTheSupertraitSubsts>` for a `dyn` type. This can be used to implement an unsound transmute function. See the committed test.

### How do we fix it?

We consider the whole trait ref when checking for supertraits. Right now, this is implemented using equality *without* normalization. We erase regions since those don't affect trait selection.

This is a limitation that could theoretically affect code that should be accepted, but doesn't matter in practice -- there are 0 crater regression. We could make this check stronger, but I would be worried about cycle issues. I assume that most people are writing `Self::Assoc` so they don't really care about the trait ref being normalized.

---

### What is up w the stacked commit

This is built on top of https://github.com/rust-lang/rust/pull/122804 though that's really not related, it's just easier to make this modification with the changes to the object safety code that I did in that PR. The only thing is that PR may make this unsoundness slightly easier to abuse, since there are more positions that allow self-associated-types -- I am happy to stall that change until this PR merges.

---

Fixes 

r? lcnr
2024-07-26 00:57:20 +02:00
..
assembly Add NuttX based targets for RISC-V and ARM 2024-07-19 22:00:42 +08:00
auxiliary
codegen Auto merge of - klensy:tests-w, r=Mark-Simulacrum 2024-07-21 03:06:32 +00:00
codegen-units Avoid MIR bloat in inlining 2024-07-01 05:17:13 -07:00
coverage Bless coverage. 2024-07-13 12:02:12 +00:00
coverage-run-rustdoc coverage: Extract hole spans from HIR instead of MIR 2024-07-08 21:22:56 +10:00
crashes Rollup merge of - compiler-errors:misused-intrinsics, r=oli-obk 2024-07-25 16:48:22 +02:00
debuginfo Add Natvis visualiser and debuginfo tests for f16 2024-07-09 03:47:50 +01:00
incremental Auto merge of - pacak:incr-uplorry, r=michaelwoerister 2024-06-20 09:06:16 +00:00
mir-opt Auto merge of - BoxyUwU:new_adt_const_params_limitations, r=compiler-errors 2024-07-21 05:36:21 +00:00
pretty Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
run-make Auto merge of - Oneirical:real-testate, r=Kobzol 2024-07-25 12:09:24 +00:00
run-pass-valgrind rustfmt tests/run-pass-valgrind/. 2024-06-04 09:53:02 +10:00
rustdoc Auto merge of - compiler-errors:impl-sorting, r=lcnr 2024-07-21 22:43:47 +00:00
rustdoc-gui Add regression test for items list size () 2024-07-22 11:33:03 +02:00
rustdoc-js rustdoc-search: use lowercase, non-normalized name for type search 2024-06-09 11:56:52 -07:00
rustdoc-js-std Update tests 2024-06-07 11:55:52 +08:00
rustdoc-json Update all rustdoc-json/ tests to use the new style 2024-07-19 16:54:42 +02:00
rustdoc-ui Rollup merge of - estebank:no-question, r=fmease 2024-07-25 04:43:20 +02:00
ui Rollup merge of - compiler-errors:supertrait-assoc-ty-unsoundness, r=lcnr 2024-07-26 00:57:20 +02:00
ui-fulldeps Auto merge of - runtimeverification:smir_serde_derive, r=celinval 2024-07-25 20:27:51 +00:00
COMPILER_TESTS.md