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: error with disjoint closure returned as impl FnMut #88331

Closed
ehuss opened this issue Aug 25, 2021 · 2 comments · Fixed by #88390
Closed

ICE: error with disjoint closure returned as impl FnMut #88331

ehuss opened this issue Aug 25, 2021 · 2 comments · Fixed by #88390
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) A-edition-2021 Area: The 2021 edition 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

@ehuss
Copy link
Contributor

ehuss commented Aug 25, 2021

The following ICE was found migrating openvpn-parser 0.5.0 to 2021 during the latest crater run: https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/openvpn-parser-0.5.0/log.txt. Error was in this closure.

cc #87988 which was very similar, but has been fixed.

Also found in:

Code

#![feature(capture_disjoint_fields)]

#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Opcode(pub u8);

impl Opcode {
    pub const OP1: Opcode = Opcode(0x1);
}

pub fn example(msg_type: Opcode) -> impl FnMut(&[u8]) {
    move |i| match msg_type {
        Opcode::OP1 => unimplemented!(),
    }
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (b03ccace5 2021-08-24)
binary: rustc
commit-hash: b03ccace573bb91e27625c190a0f7807045a1012
commit-date: 2021-08-24
host: x86_64-apple-darwin
release: 1.56.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_mir_build/src/build/matches/mod.rs:1765:53
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_mir_build/src/build/matches/mod.rs:1765:53
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_mir_build::build::matches::<impl rustc_mir_build::build::Builder>::bind_and_guard_matched_candidate
   4: rustc_mir_build::build::matches::<impl rustc_mir_build::build::Builder>::bind_pattern
   5: rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::in_scope
   6: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   7: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   8: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
   9: rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::in_scope
  10: rustc_data_structures::stack::ensure_sufficient_stack
  11: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
  12: rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::in_scope
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
  15: rustc_mir_build::build::construct_fn
  16: rustc_infer::infer::InferCtxtBuilder::enter
  17: rustc_mir_build::build::mir_built
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built
  22: rustc_mir::transform::check_unsafety::unsafety_check_result
  23: core::ops::function::FnOnce::call_once
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_data_structures::stack::ensure_sufficient_stack
  26: rustc_query_system::query::plumbing::force_query_with_job
  27: rustc_query_system::query::plumbing::get_query_impl
  28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
  29: <rustc_mir::transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_rvalue
  30: rustc_mir::transform::check_unsafety::unsafety_check_result
  31: core::ops::function::FnOnce::call_once
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::force_query_with_job
  35: rustc_query_system::query::plumbing::get_query_impl
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
  37: rustc_mir::transform::mir_const
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_data_structures::stack::ensure_sufficient_stack
  40: rustc_query_system::query::plumbing::get_query_impl
  41: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
  42: rustc_mir::transform::mir_promoted
  43: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  44: rustc_data_structures::stack::ensure_sufficient_stack
  45: rustc_query_system::query::plumbing::get_query_impl
  46: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_promoted
  47: rustc_mir::borrow_check::mir_borrowck
  48: core::ops::function::FnOnce::call_once
  49: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  50: rustc_data_structures::stack::ensure_sufficient_stack
  51: rustc_query_system::query::plumbing::force_query_with_job
  52: rustc_query_system::query::plumbing::get_query_impl
  53: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  54: rustc_typeck::collect::type_of::type_of
  55: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  56: rustc_data_structures::stack::ensure_sufficient_stack
  57: rustc_query_system::query::plumbing::force_query_with_job
  58: rustc_query_system::query::plumbing::get_query_impl
  59: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  60: rustc_typeck::check::check::check_item_type
  61: rustc_middle::hir::map::Map::visit_item_likes_in_module
  62: rustc_typeck::check::check::check_mod_item_types
  63: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  64: rustc_data_structures::stack::ensure_sufficient_stack
  65: rustc_query_system::query::plumbing::force_query_with_job
  66: rustc_query_system::query::plumbing::get_query_impl
  67: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  68: rustc_session::utils::<impl rustc_session::session::Session>::time
  69: rustc_typeck::check_crate
  70: rustc_interface::passes::analysis
  71: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  72: rustc_data_structures::stack::ensure_sufficient_stack
  73: rustc_query_system::query::plumbing::force_query_with_job
  74: rustc_query_system::query::plumbing::get_query_impl
  75: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  76: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  77: rustc_span::with_source_map
  78: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.56.0-nightly (b03ccace5 2021-08-24) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_built] building MIR for `example::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `example::{closure#0}`
#2 [unsafety_check_result] unsafety-checking `example`
#3 [mir_const] processing MIR for `example`
#4 [mir_promoted] processing `example`
#5 [mir_borrowck] borrow-checking `example`
#6 [type_of] computing type of `example::{opaque#0}`
#7 [check_mod_item_types] checking item types in top-level module
#8 [analysis] running analysis passes on this crate
end of query stack
warning: `foo` (lib) generated 1 warning
error: could not compile `foo`; 1 warning emitted```

</p>
</details>



<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

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

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->
@ehuss ehuss added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-closures Area: Closures (`|…| { … }`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-edition-2021 Area: The 2021 edition labels Aug 25, 2021
@ehuss
Copy link
Contributor Author

ehuss commented Aug 25, 2021

cc @rust-lang/wg-rfc-2229

@roxelo
Copy link
Member

roxelo commented Aug 25, 2021

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-edition-2021 Area: The 2021 edition 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.

2 participants