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: type parameter out of range -Zmir-opt-level=2 --emit=mir #78560

Closed
matthiaskrgr opened this issue Oct 30, 2020 · 2 comments · Fixed by #78674
Closed

ICE: type parameter out of range -Zmir-opt-level=2 --emit=mir #78560

matthiaskrgr opened this issue Oct 30, 2020 · 2 comments · Fixed by #78674
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. 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.

Comments

@matthiaskrgr
Copy link
Member

Code

reduced from ./src/test/ui/issues/issue-28561.rs

#[derive(Clone)]
struct Fn<A, B> {
    f02: fn(A, B)
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (0d33ab7af 2020-10-30)
binary: rustc
commit-hash: 0d33ab7af4aebe786410b4c10367eb6ddf13af0b
commit-date: 2020-10-30
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

rustc ./src/test/ui/issues/issue-28561.rs -Zmir-opt-level=2 --emit=mir

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:528:17: type parameter `B/#1` (B/1) out of range when substituting, substs=[fn(A, B)]

thread 'rustc' panicked at 'Box<Any>', /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/compiler/rustc_errors/src/lib.rs:891: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.49.0-nightly (0d33ab7af 2020-10-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=2

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<Fn<A, B> as std::clone::Clone>::clone`
end of query stack
error: aborting due to previous error
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:528:17: type parameter `B/#1` (B/1) out of range when substituting, substs=[fn(A, B)]

thread 'rustc' panicked at 'Box<Any>', /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/compiler/rustc_errors/src/lib.rs:891:9
stack backtrace:
   0:     0x7f21197865f0 - std::backtrace_rs::backtrace::libunwind::trace::h448c56741b6011d3
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7f21197865f0 - std::backtrace_rs::backtrace::trace_unsynchronized::h881b9d30a8a89a0c
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f21197865f0 - std::sys_common::backtrace::_print_fmt::h720a2f61f75b9f58
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f21197865f0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8d62bbfda6d5c836
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f21197f652c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f2119778252 - std::io::Write::write_fmt::h16a9fe7680ac245c
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/io/mod.rs:1518:15
   6:     0x7f211978b5a5 - std::sys_common::backtrace::_print::h9ba51a6db618de7d
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f211978b5a5 - std::sys_common::backtrace::print::h5f20e41c85e91716
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f211978b5a5 - std::panicking::default_hook::{{closure}}::h8d48653392f3b04c
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/panicking.rs:208:50
   9:     0x7f211978b248 - std::panicking::default_hook::hb3948d1f74b6ff4c
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/panicking.rs:227:9
  10:     0x7f211a0554b8 - rustc_driver::report_ice::h1ddbc5609a6e1f37
  11:     0x7f211978bea6 - std::panicking::rust_panic_with_hook::h55d23fef0ad751bc
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/panicking.rs:597:17
  12:     0x7f211cdb27fd - std::panicking::begin_panic::{{closure}}::hd947eabc42434d7e
  13:     0x7f211cdb2676 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48eb0455bf6d0a2
  14:     0x7f211cdb2756 - std::panicking::begin_panic::h673793876dd52a84
  15:     0x7f211cda38c5 - rustc_errors::HandlerInner::span_bug::h96d4d1f33fe11a81
  16:     0x7f211cda46c0 - rustc_errors::Handler::span_bug::hd4174033c6f30272
  17:     0x7f211cabfa64 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::hb4ddd0d3902006f3
  18:     0x7f211cab956b - rustc_middle::ty::context::tls::with_opt::{{closure}}::ha7f81bc36cab3c9f
  19:     0x7f211cab8f22 - rustc_middle::ty::context::tls::with_opt::hf0c2c2aff96e53ba
  20:     0x7f211cabf969 - rustc_middle::util::bug::opt_span_bug_fmt::hc7cbb029c2646db9
  21:     0x7f211cabf923 - rustc_middle::util::bug::span_bug_fmt::h3bf186beb4ce6b92
  22:     0x7f211cab701e - <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h5265163b4487a38a
  23:     0x7f211cc41852 - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h5dc0ab4942b60e5f
  24:     0x7f211cd92602 - rustc_middle::ty::structural_impls::fold_list::h6987b80cfa543859
  25:     0x7f211cbe0ee5 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with::hcd50cd058363ef2d
  26:     0x7f211cab6e80 - <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h5265163b4487a38a
  27:     0x7f211cbe0e95 - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with::hcd50cd058363ef2d
  28:     0x7f211cab6e80 - <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h5265163b4487a38a
  29:     0x7f211b67e213 - rustc_middle::ty::fold::TypeFoldable::fold_with::hcfc0bcab5eee2a4b
  30:     0x7f211b5ea834 - rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions::h50c1d5daecb56882
  31:     0x7f211b393dff - rustc_mir::transform::inline::Inliner::run_pass::h160d0d273d881e9b
  32:     0x7f211b39281a - <rustc_mir::transform::inline::Inline as rustc_mir::transform::MirPass>::run_pass::h616a912953f0ee0e
  33:     0x7f211b84987d - rustc_mir::transform::run_passes::h211303d522a12d5d
  34:     0x7f211b84b9d3 - rustc_mir::transform::run_optimization_passes::he68a023a63197fe9
  35:     0x7f211b84bc53 - rustc_mir::transform::optimized_mir::h9877cf2dcd224775
  36:     0x7f211b322a52 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::optimized_mir>::compute::hc1fb28a214043661
  37:     0x7f211b6bf644 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hdcbd220a91a0fa7d
  38:     0x7f211b6cf561 - rustc_data_structures::stack::ensure_sufficient_stack::h8cd2d9586b9bff8c
  39:     0x7f211b4bcbbf - rustc_query_system::query::plumbing::get_query_impl::h426160ef8626bfd8
  40:     0x7f211b3a2597 - rustc_mir::util::pretty::write_mir_pretty::ha9d3fce2e2d6083a
  41:     0x7f211b590331 - rustc_mir::transform::dump_mir::emit_mir::he6266d14022fc931
  42:     0x7f211a2a1c54 - rustc_interface::passes::QueryContext::enter::h9b049407f643d454
  43:     0x7f211a2c1933 - rustc_interface::queries::Queries::ongoing_codegen::h90e1d78cee1f0a3b
  44:     0x7f211a0723a0 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h25b522245624a405
  45:     0x7f211a035a2f - rustc_span::with_source_map::h7455fffe3cd153a4
  46:     0x7f211a06d4f1 - scoped_tls::ScopedKey<T>::set::h8ae8151712a551fd
  47:     0x7f211a077c25 - std::sys_common::backtrace::__rust_begin_short_backtrace::h26de371bc27662fc
  48:     0x7f2119fdf648 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h80d1a8eb7971174b
  49:     0x7f211979aeaa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e7afb7a0a438236
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/alloc/src/boxed.rs:1307:9
  50:     0x7f211979aeaa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70c646c4271337a1
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/alloc/src/boxed.rs:1307:9
  51:     0x7f211979aeaa - std::sys::unix::thread::Thread::new::thread_start::h35d2b8d36f210d02
                               at /rustc/0d33ab7af4aebe786410b4c10367eb6ddf13af0b/library/std/src/sys/unix/thread.rs:89:17
  52:     0x7f21196963e9 - start_thread
  53:     0x7f21195b3293 - __GI___clone
  54:                0x0 - <unknown>

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.49.0-nightly (0d33ab7af 2020-10-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=2

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<Fn<A, B> as std::clone::Clone>::clone`
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. 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. labels Oct 30, 2020
@jonas-schievink jonas-schievink added the A-mir-opt Area: MIR optimizations label Oct 30, 2020
@tmiasko
Copy link
Contributor

tmiasko commented Oct 30, 2020

Looks like the same inliner issue as in #78529.

@matthiaskrgr
Copy link
Member Author

cargo bisect rustc says this happens since 0da6d42

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 6, 2020
… r=oli-obk

inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves rust-lang#78529.
Resolves rust-lang#78560.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 8, 2020
… r=oli-obk

inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves rust-lang#78529.
Resolves rust-lang#78560.
@bors bors closed this as completed in b4589a8 Nov 9, 2020
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Nov 27, 2020
… r=oli-obk

inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves rust-lang#78529.
Resolves rust-lang#78560.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants