Repository: rust
Issue: error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize
Labels: I-ICE,T-compiler,C-bug,A-const-generics,E-needs-mcve

<!--
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

The code cannot easily be entirely summarised in a small segment. It involves a [criterion benchmark](https://github.com/bheisler/criterion.rs) on a library.

Specifically running `cargo bench` in on this branch (https://github.com/JonathanWoollett-Light/static-la/tree/bench-error) triggers the error.

### 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.58.0-nightly (82af160c2 2021-11-10)
binary: rustc
commit-hash: 82af160c2cb9c349a0373cba98d8ad7f911f0d34
commit-date: 2021-11-10
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
```

### Error output

```
error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<static_la::MatrixSxS<T, L, M> as static_la::Matmul<static_la::MatrixSxS<T, M, N>>>::Output`

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

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.58.0-nightly (82af160c2 2021-11-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<static_la::MatrixSxS<T, L, M> as static_la::matmul::Matmul<static_la::MatrixSxS<T, M, N>>>::Output`
#1 [fn_abi_of_instance] computing call ABI of `<static_la::MatrixSxS<i32, 2_usize, 3_usize> as static_la::matmul::Matmul<static_la::MatrixSxS<i32, 3_usize, 2_usize>>>::matmul`
end of query stack
warning: `static-la` (bench "benchmarks") generated 12 warnings
error: could not compile `static-la`; 12 warnings emitted
warning: build failed, waiting for other jobs to finish...
error: build failed
jonathan@jonathan-MS-7B22:~/Projects/static-la$ 
```

<!--
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>

```
error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<static_la::MatrixSxS<T, L, M> as static_la::Matmul<static_la::MatrixSxS<T, M, N>>>::Output`

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug
   3: <rustc_errors::Handler>::bug
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_infer::infer::InferCtxtBuilder>::enter::<rustc_middle::ty::subst::GenericArg, rustc_traits::normalize_erasing_regions::normalize_after_erasing_regions<rustc_middle::ty::subst::GenericArg>::{closure#0}>
   8: <rustc_traits::normalize_erasing_regions::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::subst::GenericArg>)>>::call_once
   9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::subst::GenericArg>, rustc_middle::ty::subst::GenericArg>>
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_generic_arg_after_erasing_regions
  11: rustc_middle::ty::util::fold_list::<rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder, &rustc_middle::ty::TyS, <&rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::fold::TypeFoldable>::super_fold_with<rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>::{closure#0}>
  12: rustc_middle::ty::layout::fn_abi_of_instance
  13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<&rustc_middle::ty::TyS>)>, core::result::Result<&rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS>, rustc_middle::ty::layout::FnAbiError>>>
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::fn_abi_of_instance
  15: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  16: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  17: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  18: rustc_codegen_llvm::base::compile_codegen_unit
  19: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  20: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  21: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
  22: <rustc_interface::queries::Queries>::ongoing_codegen
  23: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  24: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

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.58.0-nightly (82af160c2 2021-11-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<static_la::MatrixSxS<T, L, M> as static_la::matmul::Matmul<static_la::MatrixSxS<T, M, N>>>::Output`
#1 [fn_abi_of_instance] computing call ABI of `<static_la::MatrixSxS<i32, 2_usize, 3_usize> as static_la::matmul::Matmul<static_la::MatrixSxS<i32, 3_usize, 2_usize>>>::matmul`
end of query stack
warning: `static-la` (bench "benchmarks") generated 12 warnings
error: could not compile `static-la`; 12 warnings emitted
jonathan@jonathan-MS-7B22:~/Projects/static-la$ 
```

</p>
</details>