From 7a96957f6439243ecf327d34d4bf5d464391e7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 3 Nov 2023 13:01:04 +0100 Subject: [PATCH] add test for #113272 error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:195:90: Failed to normalize <() as Trait>::RefTarget, maybe try to call `try_normalize_erasing_regions` instead Fixes #113272 --- .../missing-bound-normalization-ice-113272.rs | 19 +++++++++++++++++++ ...sing-bound-normalization-ice-113272.stderr | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/ui/transmute/missing-bound-normalization-ice-113272.rs create mode 100644 tests/ui/transmute/missing-bound-normalization-ice-113272.stderr diff --git a/tests/ui/transmute/missing-bound-normalization-ice-113272.rs b/tests/ui/transmute/missing-bound-normalization-ice-113272.rs new file mode 100644 index 0000000000000..3e42d1329d02b --- /dev/null +++ b/tests/ui/transmute/missing-bound-normalization-ice-113272.rs @@ -0,0 +1,19 @@ +// test for ICE #113272 Failed to normalize <() as Trait>::RefTarget ... + +trait Trait { + type RefTarget; +} + +impl Trait for () where Missing: Trait {} +//~^ ERROR: cannot find type `Missing` in this scope +//~^^ ERROR: not all trait items implemented, missing: `RefTarget` + +struct Other { + data: <() as Trait>::RefTarget, +} + +fn main() { + unsafe { + std::mem::transmute::, Option<&Other>>(None); + } +} diff --git a/tests/ui/transmute/missing-bound-normalization-ice-113272.stderr b/tests/ui/transmute/missing-bound-normalization-ice-113272.stderr new file mode 100644 index 0000000000000..e6b0bb3b002fe --- /dev/null +++ b/tests/ui/transmute/missing-bound-normalization-ice-113272.stderr @@ -0,0 +1,19 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/missing-bound-normalization-ice-113272.rs:7:25 + | +LL | impl Trait for () where Missing: Trait {} + | ^^^^^^^ not found in this scope + +error[E0046]: not all trait items implemented, missing: `RefTarget` + --> $DIR/missing-bound-normalization-ice-113272.rs:7:1 + | +LL | type RefTarget; + | -------------- `RefTarget` from trait +... +LL | impl Trait for () where Missing: Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0046, E0412. +For more information about an error, try `rustc --explain E0046`.