Skip to content

ICE On while Some(_) instead of while let Some(_) #80288

Closed
@Moggers

Description

@Moggers

In the below snippet, I forgot the let in while let Some(_) =, and this caused an ICE.

Code

while Some(v) = v.next_element::<i32>()? {
   last = Ok(v)
}

Meta

rustc 1.48.0-nightly (7f7a1cbfd 2020-09-27)
binary: rustc
commit-hash: 7f7a1cbfd3b55daee191247770627afab09eece2
commit-date: 2020-09-27
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: 11.0

Error output

matthew@archlinux ~/g/blitzserver (master)> cargo run
   Compiling blitzserver v0.1.2 (/home/matthew/git/blitzserver)
error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt.rs:459:25: while adjusting Expr { hir_id: HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 60 }, kind: Path(Resolved(None, Path { span: src/frontend/games.rs:110:29: 110:30 (#0), res: Local(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 2 }), segments: [PathSegment { ident: v#0, hir_id: Some(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 59 }), res: Some(Local(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 2 })), args: None, infer_args: true }] })), attrs: ThinVec(None), span: src/frontend/games.rs:110:29: 110:30 (#0) }, can't compose [Borrow(Ref('_#20r, Mut { allow_two_phase_borrow: Yes })) -> &mut A] and [Borrow(Ref('_#23r, Mut { allow_two_phase_borrow: Yes })) -> &mut A]

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945: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.48.0-nightly (7f7a1cbfd 2020-09-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

error: aborting due to previous error

error: could not compile `blitzserver````

Backtrace

matthew@archlinux ~/g/blitzserver (master)> RUST_BACKTRACE=1 cargo build
   Compiling blitzserver v0.1.2 (/home/matthew/git/blitzserver)
    Building [=====================================================> ] 335/336: blitzserver(bin)
error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt.rs:459:25: while adjusting Expr { hir_id: HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 68 }, kind: Path(Resolved(None, Path { span: src/frontend/games.rs:110:29: 110:30 (#0), res: Local(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 2 }), segments: [PathSegment { ident: v#0, hir_id: Some(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 67 }), res: Some(Local(HirId { owner: DefId(0:121 ~ blitzserver[e8ee]::frontend::games::de_map_to_scalar::{impl#0}::visit_seq), local_id: 2 })), args: None, infer_args: true }] })), attrs: ThinVec(None), span: src/frontend/games.rs:110:29: 110:30 (#0) }, can't compose [Borrow(Ref('_#20r, Mut { allow_two_phase_borrow: Yes })) -> &mut A] and [Borrow(Ref('_#23r, Mut { allow_two_phase_borrow: Yes })) -> &mut A]

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_typeck::check::fn_ctxt::FnCtxt::apply_adjustments
   9: rustc_typeck::check::method::confirm::ConfirmContext::confirm
  10: rustc_typeck::check::method::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::lookup_method
  11: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  12: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  13: rustc_typeck::check::fn_ctxt::FnCtxt::check_argument_types
  14: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  15: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  16: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  17: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  18: rustc_typeck::check::_match::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  19: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_coercable_to_type
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  24: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  26: rustc_typeck::check::_match::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  27: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  29: rustc_typeck::check::fn_ctxt::FnCtxt::check_block_with_expected
  30: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  31: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  32: rustc_typeck::check::fn_ctxt::FnCtxt::check_stmt
  33: rustc_typeck::check::fn_ctxt::FnCtxt::check_block_with_expected
  34: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  35: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  36: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  37: rustc_typeck::check::check::check_fn
  38: rustc_infer::infer::InferCtxtBuilder::enter
  39: rustc_typeck::check::typeck
  40: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  41: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  43: rustc_data_structures::stack::ensure_sufficient_stack
  44: rustc_query_system::query::plumbing::get_query_impl
  45: rustc_query_system::query::plumbing::ensure_query_impl
  46: rustc_typeck::check::typeck_item_bodies
  47: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  48: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  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::get_query_impl
  52: rustc_typeck::check_crate
  53: rustc_interface::passes::analysis
  54: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  55: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  56: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  57: rustc_data_structures::stack::ensure_sufficient_stack
  58: rustc_query_system::query::plumbing::get_query_impl
  59: rustc_interface::passes::QueryContext::enter
  60: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  61: rustc_span::with_source_map
  62: rustc_interface::interface::create_compiler_and_run
  63: scoped_tls::ScopedKey<T>::set
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.48.0-nightly (7f7a1cbfd 2020-09-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `<frontend::games::de_map_to_scalar::MapVisitor as _::_serde::de::Visitor<'de>>::visit_seq`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `blitzserver`

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions