Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: inherent_associated_types: Unexpected parameter Type(S<'a>) when substituting in region 'a (index=0) with -Zdump-mir=all #111390

Closed
matthiaskrgr opened this issue May 9, 2023 · 2 comments · Fixed by #111486
Assignees
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 9, 2023

Code

rustc -Zdump-mir=all late-bound-regions.rs

#![feature(inherent_associated_types)]

type Function = for<'a> fn(&'a i32) -> S<'a>::P;

struct S<'a>(&'a ());

impl<'a> S<'a> {
    type P = &'a i32;
}

fn ret_ref_local<'e>() -> &'e i32 {
    let f: Function = |x| x;

    let local = 0;
    f(&local) 
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (2f2c438dc 2023-05-08)
binary: rustc
commit-hash: 2f2c438dce75d8cc532c3baa849eeddc0901802c
commit-date: 2023-05-08
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:810:13: Unexpected parameter Type(S<'a>) when substituting in region 'a (index=0)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/compiler/rustc_errors/src/lib.rs:1650:9
stack backtrace:
   0:     0x7ff285946361 - std::backtrace_rs::backtrace::libunwind::trace::he9e9030cf5bcddaa
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff285946361 - std::backtrace_rs::backtrace::trace_unsynchronized::hb5e44a77ff0586eb
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff285946361 - std::sys_common::backtrace::_print_fmt::h38e8723c5d83f22f
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ff285946361 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e394c4b1f1cb045
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff2859a66ff - core::fmt::rt::Argument::fmt::ha5dde4cb71578cc2
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/rt.rs:138:9
   5:     0x7ff2859a66ff - core::fmt::write::hb1413899fd777907
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs:1094:21
   6:     0x7ff2859395c1 - std::io::Write::write_fmt::h08b4eac68313bb0d
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/io/mod.rs:1712:15
   7:     0x7ff285946175 - std::sys_common::backtrace::_print::h2bb25f41b1777226
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff285946175 - std::sys_common::backtrace::print::ha21981aa5a1c5802
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff285948e07 - std::panicking::default_hook::{{closure}}::h603ce04329232051
  10:     0x7ff285948bf4 - std::panicking::default_hook::hd4285764fbdb24e1
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/panicking.rs:288:9
  11:     0x7ff2847bf94b - <rustc_driver_impl[27c68de0ac55b06a]::install_ice_hook::{closure#0} as core[3afeaedfb140cde7]::ops::function::FnOnce<(&core[3afeaedfb140cde7]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7ff285949527 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h401f21a7538313bc
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/alloc/src/boxed.rs:1999:9
  13:     0x7ff285949527 - std::panicking::rust_panic_with_hook::h2322eda2481f33bc
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/panicking.rs:695:13
  14:     0x7ff284cae031 - std[53b54636b4f52653]::panicking::begin_panic::<rustc_errors[2afb0e2cc7c4c42d]::ExplicitBug>::{closure#0}
  15:     0x7ff284caa7e6 - std[53b54636b4f52653]::sys_common::backtrace::__rust_end_short_backtrace::<std[53b54636b4f52653]::panicking::begin_panic<rustc_errors[2afb0e2cc7c4c42d]::ExplicitBug>::{closure#0}, !>
  16:     0x7ff284caa6d6 - std[53b54636b4f52653]::panicking::begin_panic::<rustc_errors[2afb0e2cc7c4c42d]::ExplicitBug>
  17:     0x7ff284ca5264 - <rustc_errors[2afb0e2cc7c4c42d]::HandlerInner>::bug::<alloc[a4f318becb59a05]::string::String>
  18:     0x7ff284ca4d76 - <rustc_errors[2afb0e2cc7c4c42d]::Handler>::bug::<alloc[a4f318becb59a05]::string::String>
  19:     0x7ff284d31bac - rustc_middle[232bd29a687eeda3]::util::bug::opt_span_bug_fmt::<rustc_span[811089187935bcb6]::span_encoding::Span>::{closure#0}
  20:     0x7ff284d3137a - rustc_middle[232bd29a687eeda3]::ty::context::tls::with_opt::<rustc_middle[232bd29a687eeda3]::util::bug::opt_span_bug_fmt<rustc_span[811089187935bcb6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff284d3134a - rustc_middle[232bd29a687eeda3]::ty::context::tls::with_context_opt::<rustc_middle[232bd29a687eeda3]::ty::context::tls::with_opt<rustc_middle[232bd29a687eeda3]::util::bug::opt_span_bug_fmt<rustc_span[811089187935bcb6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff2829c8f8d - rustc_middle[232bd29a687eeda3]::util::bug::bug_fmt
  23:     0x7ff284cb7731 - <rustc_middle[232bd29a687eeda3]::ty::subst::SubstFolder as rustc_type_ir[cc09a4b81b2ca552]::fold::TypeFolder<rustc_middle[232bd29a687eeda3]::ty::context::TyCtxt>>::fold_region::region_param_invalid
  24:     0x7ff2827ae0c9 - <rustc_middle[232bd29a687eeda3]::ty::subst::GenericArg as rustc_type_ir[cc09a4b81b2ca552]::fold::TypeFoldable<rustc_middle[232bd29a687eeda3]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[232bd29a687eeda3]::ty::subst::SubstFolder>
  25:     0x7ff2827abe46 - <rustc_middle[232bd29a687eeda3]::ty::Ty as rustc_type_ir[cc09a4b81b2ca552]::fold::TypeSuperFoldable<rustc_middle[232bd29a687eeda3]::ty::context::TyCtxt>>::super_fold_with::<rustc_middle[232bd29a687eeda3]::ty::subst::SubstFolder>
  26:     0x7ff28290ae4b - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter as rustc_middle[232bd29a687eeda3]::ty::print::Printer>::print_def_path
  27:     0x7ff28290a7c6 - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter as rustc_middle[232bd29a687eeda3]::ty::print::Printer>::print_def_path
  28:     0x7ff282907f2b - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter as rustc_middle[232bd29a687eeda3]::ty::print::pretty::PrettyPrinter>::pretty_print_type
  29:     0x7ff284d38036 - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter as rustc_middle[232bd29a687eeda3]::ty::print::pretty::PrettyPrinter>::pretty_fn_sig
  30:     0x7ff284cfae2f - <rustc_middle[232bd29a687eeda3]::ty::sty::FnSig as rustc_middle[232bd29a687eeda3]::ty::print::Print<rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter>>::print
  31:     0x7ff284d409f2 - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter>::pretty_in_binder::<rustc_middle[232bd29a687eeda3]::ty::sty::FnSig>
  32:     0x7ff28290903b - <rustc_middle[232bd29a687eeda3]::ty::print::pretty::FmtPrinter as rustc_middle[232bd29a687eeda3]::ty::print::pretty::PrettyPrinter>::pretty_print_type
  33:     0x7ff28290752c - <rustc_middle[232bd29a687eeda3]::ty::Ty as core[3afeaedfb140cde7]::fmt::Display>::fmt
  34:     0x7ff284d51a28 - <rustc_middle[232bd29a687eeda3]::ty::Ty as core[3afeaedfb140cde7]::fmt::Debug>::fmt
  35:     0x7ff2859a360c - core::fmt::builders::DebugTuple::field::{{closure}}::hae8bf7adeee9f6a5
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/builders.rs:322:17
  36:     0x7ff2859a360c - core::result::Result<T,E>::and_then::h929eb9fc8e20a049
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/result.rs:1319:22
  37:     0x7ff2859a360c - core::fmt::builders::DebugTuple::field::h3d7fca7c97960413
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/builders.rs:309:35
  38:     0x7ff2859a7b1b - core::fmt::Formatter::debug_tuple_field1_finish::h4e6f73694bf6c84f
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs:2023:9
  39:     0x7ff284c64cea - <rustc_middle[232bd29a687eeda3]::ty::typeck_results::UserType as core[3afeaedfb140cde7]::fmt::Debug>::fmt
  40:     0x7ff2859a3379 - core::fmt::builders::DebugStruct::field::{{closure}}::h473ac448a7c4116a
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/builders.rs:141:17
  41:     0x7ff2859a3379 - core::result::Result<T,E>::and_then::hbb9e091b5a5e90dc
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/result.rs:1319:22
  42:     0x7ff2859a3379 - core::fmt::builders::DebugStruct::field::h4e3ae4a6f27f2d47
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/builders.rs:124:35
  43:     0x7ff2859a7696 - core::fmt::Formatter::debug_struct_field3_finish::h38cd8cf3f886f443
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs:1911:9
  44:     0x7ff284cf81ed - <rustc_middle[232bd29a687eeda3]::infer::canonical::Canonical<rustc_middle[232bd29a687eeda3]::ty::typeck_results::UserType> as core[3afeaedfb140cde7]::fmt::Debug>::fmt
  45:     0x7ff2859a66ff - core::fmt::rt::Argument::fmt::ha5dde4cb71578cc2
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/rt.rs:138:9
  46:     0x7ff2859a66ff - core::fmt::write::hb1413899fd777907
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs:1094:21
  47:     0x7ff284e79100 - <std[53b54636b4f52653]::io::buffered::bufwriter::BufWriter<std[53b54636b4f52653]::fs::File> as std[53b54636b4f52653]::io::Write>::write_fmt
  48:     0x7ff284c8fd4b - rustc_middle[232bd29a687eeda3]::mir::pretty::write_user_type_annotations
  49:     0x7ff284e587ee - rustc_middle[232bd29a687eeda3]::mir::pretty::dump_matched_mir_node::<rustc_mir_transform[bd425728c1433367]::pass_manager::dump_mir_for_phase_change::{closure#0}>
  50:     0x7ff283840fc6 - rustc_mir_transform[bd425728c1433367]::mir_const
  51:     0x7ff28383e853 - rustc_query_system[8be5ea0cc4c28ea6]::query::plumbing::try_execute_query::<rustc_query_impl[94005537e54250be]::queries::mir_const, rustc_query_impl[94005537e54250be]::plumbing::QueryCtxt>
  52:     0x7ff28383e4f5 - rustc_query_impl[94005537e54250be]::get_query::mir_const
  53:     0x7ff2836541a1 - rustc_mir_transform[bd425728c1433367]::mir_promoted
  54:     0x7ff28318dbea - rustc_query_system[8be5ea0cc4c28ea6]::query::plumbing::try_execute_query::<rustc_query_impl[94005537e54250be]::queries::mir_promoted, rustc_query_impl[94005537e54250be]::plumbing::QueryCtxt>
  55:     0x7ff28318cf5c - rustc_borrowck[2561add2bcb16522]::mir_borrowck
  56:     0x7ff28318b748 - rustc_query_system[8be5ea0cc4c28ea6]::query::plumbing::try_execute_query::<rustc_query_impl[94005537e54250be]::queries::mir_borrowck, rustc_query_impl[94005537e54250be]::plumbing::QueryCtxt>
  57:     0x7ff283bef386 - rustc_data_structures[fba7df231146955e]::sync::par_for_each_in::<&[rustc_span[811089187935bcb6]::def_id::LocalDefId], <rustc_middle[232bd29a687eeda3]::hir::map::Map>::par_body_owners<rustc_interface[1005215f39c21569]::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>
  58:     0x7ff283be9f80 - rustc_interface[1005215f39c21569]::passes::analysis
  59:     0x7ff283f2bd47 - rustc_query_system[8be5ea0cc4c28ea6]::query::plumbing::try_execute_query::<rustc_query_impl[94005537e54250be]::queries::analysis, rustc_query_impl[94005537e54250be]::plumbing::QueryCtxt>
  60:     0x7ff283f2ba63 - rustc_query_impl[94005537e54250be]::get_query::analysis
  61:     0x7ff2839ccbcf - <rustc_middle[232bd29a687eeda3]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[27c68de0ac55b06a]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>>
  62:     0x7ff2839cbcaf - <rustc_interface[1005215f39c21569]::interface::Compiler>::enter::<rustc_driver_impl[27c68de0ac55b06a]::run_compiler::{closure#1}::{closure#2}, core[3afeaedfb140cde7]::result::Result<core[3afeaedfb140cde7]::option::Option<rustc_interface[1005215f39c21569]::queries::Linker>, rustc_span[811089187935bcb6]::ErrorGuaranteed>>
  63:     0x7ff2839c933b - std[53b54636b4f52653]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1005215f39c21569]::util::run_in_thread_pool_with_globals<rustc_interface[1005215f39c21569]::interface::run_compiler<core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>, rustc_driver_impl[27c68de0ac55b06a]::run_compiler::{closure#1}>::{closure#0}, core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>>
  64:     0x7ff284098f55 - <<std[53b54636b4f52653]::thread::Builder>::spawn_unchecked_<rustc_interface[1005215f39c21569]::util::run_in_thread_pool_with_globals<rustc_interface[1005215f39c21569]::interface::run_compiler<core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>, rustc_driver_impl[27c68de0ac55b06a]::run_compiler::{closure#1}>::{closure#0}, core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3afeaedfb140cde7]::result::Result<(), rustc_span[811089187935bcb6]::ErrorGuaranteed>>::{closure#1} as core[3afeaedfb140cde7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  65:     0x7ff2859539d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h20fe0a24dda744f1
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/alloc/src/boxed.rs:1985:9
  66:     0x7ff2859539d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb11b4529d66356f4
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/alloc/src/boxed.rs:1985:9
  67:     0x7ff2859539d5 - std::sys::unix::thread::Thread::new::thread_start::h896be1b4ceadbc98
                               at /rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/sys/unix/thread.rs:108:17
  68:     0x7ff281465bb5 - <unknown>
  69:     0x7ff2814e7d90 - <unknown>
  70:                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 (2f2c438dc 2023-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir=all

query stack during panic:
#0 [mir_const] preparing `ret_ref_local` for borrow checking
#1 [mir_promoted] promoting constants in MIR for `ret_ref_local`
#2 [mir_borrowck] borrow-checking `ret_ref_local`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. F-inherent_associated_types `#![feature(inherent_associated_types)]` labels May 9, 2023
@matthiaskrgr
Copy link
Member Author

Regression in 7b55296
#105961
cc @fmease

@fmease
Copy link
Member

fmease commented May 9, 2023

Thanks :)

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants