Repository: rust
Issue: ICE: cfi: TAIT `transform_ty: unexpected `Alias(Opaque`
Labels: I-ICE,T-compiler,A-sanitizers,C-bug,F-type_alias_impl_trait,requires-nightly,PG-exploit-mitigations

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code
build with ` -Zsanitizer=cfi   -Clto`
```Rust
#![feature(type_alias_impl_trait)]

trait T {
    type Item;
}

type Alias<'a> = impl T;

struct S;
impl<'a> T for &'a S {
    type Item = &'a ();
}

fn filter_positive<'a>() -> Alias<'a> {
    &S
}

fn with_positive(fun: impl Fn(Alias<'_>)) {}

fn main() {
    with_positive(|_| ());
}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.71.0-nightly (6f8c0557e 2023-05-04)
binary: rustc
commit-hash: 6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c
commit-date: 2023-05-04
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
```

### Error output

```

```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
warning: unused variable: `fun`
  --> treereduce.out:18:18
   |
18 | fn with_positive(fun: impl Fn(Alias<'_>)) {}
   |                  ^^^ help: if this is intentional, prefix it with an underscore: `_fun`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: function `filter_positive` is never used
  --> treereduce.out:14:4
   |
14 | fn filter_positive<'a>() -> Alias<'a> {
   |    ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

error: internal compiler error: compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs:881:13: transform_ty: unexpected `Alias(Opaque, AliasTy { substs: [ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) })], def_id: DefId(0:17 ~ treereduce[9f90]::Alias::{opaque#0}) })`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/compiler/rustc_errors/src/lib.rs:1643:9
stack backtrace:
   0:     0x7f4e28569441 - std::backtrace_rs::backtrace::libunwind::trace::ha1124e3c4b659eb5
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4e28569441 - std::backtrace_rs::backtrace::trace_unsynchronized::h3a8d622ec81b6cb5
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4e28569441 - std::sys_common::backtrace::_print_fmt::h2128e938c7086b6e
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f4e28569441 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc50c3543d0b1b52f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f4e285ca0df - core::fmt::rt::Argument::fmt::h84c36e9580f5b71f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/core/src/fmt/rt.rs:138:9
   5:     0x7f4e285ca0df - core::fmt::write::h326e01f7a9aa5dd9
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f4e2855c4f1 - std::io::Write::write_fmt::h71f0f6281149b8c8
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/io/mod.rs:1712:15
   7:     0x7f4e28569255 - std::sys_common::backtrace::_print::h6b9c2111a065fb89
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f4e28569255 - std::sys_common::backtrace::print::hf8d0af7625f66057
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f4e2856bee7 - std::panicking::default_hook::{{closure}}::h630fe7740556559d
  10:     0x7f4e2856bcd4 - std::panicking::default_hook::h337047625b381696
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/panicking.rs:288:9
  11:     0x7f4e2b771715 - rustc_driver_impl[f38315262de66e12]::DEFAULT_HOOK::{closure#0}::{closure#0}
  12:     0x7f4e2856c607 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1ac669e77ecf459f
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1999:9
  13:     0x7f4e2856c607 - std::panicking::rust_panic_with_hook::h22ef26cea64ec65c
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/panicking.rs:695:13
  14:     0x7f4e2bc39901 - std[2e06b57a958d7603]::panicking::begin_panic::<rustc_errors[5778b576bff5e43e]::ExplicitBug>::{closure#0}
  15:     0x7f4e2bc392a6 - std[2e06b57a958d7603]::sys_common::backtrace::__rust_end_short_backtrace::<std[2e06b57a958d7603]::panicking::begin_panic<rustc_errors[5778b576bff5e43e]::ExplicitBug>::{closure#0}, !>
  16:     0x7f4e2bc5fca6 - std[2e06b57a958d7603]::panicking::begin_panic::<rustc_errors[5778b576bff5e43e]::ExplicitBug>
  17:     0x7f4e2bc5d114 - <rustc_errors[5778b576bff5e43e]::HandlerInner>::bug::<alloc[3df6c3833cdafa3e]::string::String>
  18:     0x7f4e2bc5ce46 - <rustc_errors[5778b576bff5e43e]::Handler>::bug::<alloc[3df6c3833cdafa3e]::string::String>
  19:     0x7f4e2bce52cc - rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt::<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}
  20:     0x7f4e2bce4afa - rustc_middle[9b03ef73197c8750]::ty::context::tls::with_opt::<rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f4e2bce4aca - rustc_middle[9b03ef73197c8750]::ty::context::tls::with_context_opt::<rustc_middle[9b03ef73197c8750]::ty::context::tls::with_opt<rustc_middle[9b03ef73197c8750]::util::bug::opt_span_bug_fmt<rustc_span[e5d9edf586a8e474]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f4e29e50ccd - rustc_middle[9b03ef73197c8750]::util::bug::bug_fmt
  23:     0x7f4e2c1c9752 - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  24:     0x7f4e2c1d2a4a - <rustc_middle[9b03ef73197c8750]::ty::Ty as rustc_type_ir[2476610ddda7a73]::CollectAndApply<rustc_middle[9b03ef73197c8750]::ty::Ty, rustc_middle[9b03ef73197c8750]::ty::Ty>>::collect_and_apply::<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::iter::adapters::copied::Copied<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::Ty>>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty::{closure#0}>, <rustc_middle[9b03ef73197c8750]::ty::context::TyCtxt>::mk_tup_from_iter<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::iter::adapters::copied::Copied<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::Ty>>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty::{closure#0}>, rustc_middle[9b03ef73197c8750]::ty::Ty>::{closure#0}>
  25:     0x7f4e2c1c8f9e - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  26:     0x7f4e2c1dcef6 - <core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::Ty>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty::{closure#2}> as core[351080cb3919538e]::iter::traits::iterator::Iterator>::fold::<(), core[351080cb3919538e]::iter::traits::iterator::Iterator::for_each::call<rustc_middle[9b03ef73197c8750]::ty::Ty, <alloc[3df6c3833cdafa3e]::vec::Vec<rustc_middle[9b03ef73197c8750]::ty::Ty>>::extend_trusted<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::Ty>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty::{closure#2}>>::{closure#0}>::{closure#0}>
  27:     0x7f4e2c1ce388 - <alloc[3df6c3833cdafa3e]::vec::Vec<rustc_middle[9b03ef73197c8750]::ty::Ty> as alloc[3df6c3833cdafa3e]::vec::spec_from_iter::SpecFromIter<rustc_middle[9b03ef73197c8750]::ty::Ty, core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::Ty>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty::{closure#2}>>>::from_iter
  28:     0x7f4e2c1c9269 - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  29:     0x7f4e2c1c5613 - <&mut rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_substs::{closure#0} as core[351080cb3919538e]::ops::function::FnOnce<(rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg,)>>::call_once
  30:     0x7f4e2c1d4beb - <smallvec[163c2c57480b45e5]::SmallVec<[rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg; 8usize]> as core[351080cb3919538e]::iter::traits::collect::Extend<<[rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg; 8usize] as smallvec[163c2c57480b45e5]::Array>::Item>>::extend::<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::iter::adapters::copied::Copied<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg>>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_substs::{closure#0}>>
  31:     0x7f4e2c1cf19e - <rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg as rustc_type_ir[2476610ddda7a73]::CollectAndApply<rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg, &rustc_middle[9b03ef73197c8750]::ty::list::List<rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg>>>::collect_and_apply::<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::iter::adapters::copied::Copied<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg>>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_substs::{closure#0}>, <rustc_middle[9b03ef73197c8750]::ty::context::TyCtxt>::mk_substs_from_iter<core[351080cb3919538e]::iter::adapters::map::Map<core[351080cb3919538e]::iter::adapters::copied::Copied<core[351080cb3919538e]::slice::iter::Iter<rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg>>, rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_substs::{closure#0}>, rustc_middle[9b03ef73197c8750]::ty::subst::GenericArg>::{closure#0}>
  32:     0x7f4e2c1c9170 - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::transform_ty
  33:     0x7f4e2c1c9f1a - rustc_symbol_mangling[1bf499ff7f75842a]::typeid::typeid_itanium_cxx_abi::typeid_for_fnabi
  34:     0x7f4e29d7059f - <rustc_codegen_llvm[d78081c433bf4e31]::context::CodegenCx as rustc_codegen_ssa[7c934ba332e0ab85]::traits::declare::PreDefineMethods>::predefine_fn
  35:     0x7f4e2ac1a0dd - rustc_codegen_llvm[d78081c433bf4e31]::base::compile_codegen_unit::module_codegen
  36:     0x7f4e2ac18fb0 - rustc_codegen_llvm[d78081c433bf4e31]::base::compile_codegen_unit
  37:     0x7f4e2ae5c416 - rustc_codegen_ssa[7c934ba332e0ab85]::base::codegen_crate::<rustc_codegen_llvm[d78081c433bf4e31]::LlvmCodegenBackend>
  38:     0x7f4e2ae5bce2 - <rustc_codegen_llvm[d78081c433bf4e31]::LlvmCodegenBackend as rustc_codegen_ssa[7c934ba332e0ab85]::traits::backend::CodegenBackend>::codegen_crate
  39:     0x7f4e2a9ff8e0 - rustc_interface[32f66f6c15b482f4]::passes::start_codegen
  40:     0x7f4e2a9facc7 - <rustc_middle[9b03ef73197c8750]::ty::context::GlobalCtxt>::enter::<<rustc_interface[32f66f6c15b482f4]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<alloc[3df6c3833cdafa3e]::boxed::Box<dyn core[351080cb3919538e]::any::Any>, rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  41:     0x7f4e2a9fa2a8 - <rustc_interface[32f66f6c15b482f4]::queries::Queries>::ongoing_codegen
  42:     0x7f4e2a9f99e3 - <rustc_interface[32f66f6c15b482f4]::interface::Compiler>::enter::<rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}::{closure#2}, core[351080cb3919538e]::result::Result<core[351080cb3919538e]::option::Option<rustc_interface[32f66f6c15b482f4]::queries::Linker>, rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  43:     0x7f4e2a9f714f - std[2e06b57a958d7603]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[32f66f6c15b482f4]::util::run_in_thread_pool_with_globals<rustc_interface[32f66f6c15b482f4]::interface::run_compiler<core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>, rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}>::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>
  44:     0x7f4e2b058a1e - <<std[2e06b57a958d7603]::thread::Builder>::spawn_unchecked_<rustc_interface[32f66f6c15b482f4]::util::run_in_thread_pool_with_globals<rustc_interface[32f66f6c15b482f4]::interface::run_compiler<core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>, rustc_driver_impl[f38315262de66e12]::run_compiler::{closure#1}>::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[351080cb3919538e]::result::Result<(), rustc_span[e5d9edf586a8e474]::ErrorGuaranteed>>::{closure#1} as core[351080cb3919538e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f4e28576ad5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he4e640066a72afb4
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1985:9
  46:     0x7f4e28576ad5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6a43b4ec147b3dd9
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/alloc/src/boxed.rs:1985:9
  47:     0x7f4e28576ad5 - std::sys::unix::thread::Thread::new::thread_start::h8c269a865bc351fb
                               at /rustc/6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7f4e28312bb5 - <unknown>
  49:     0x7f4e28394d90 - <unknown>
  50:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.71.0-nightly (6f8c0557e 2023-05-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z sanitizer=cfi -C lto

query stack during panic:
end of query stack
error: aborting due to previous error; 2 warnings emitted
```

</p>
</details>


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"rcvalle"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->