Skip to content

"DefId isn't local" ICE #81839

Closed
Closed
@layderv

Description

@layderv

Code

The code is based on this example and the following git diff: https://github.com/teloxide/teloxide/tree/dev/examples/sqlite_remember_bot (commit fe6429c2790502ae09b04d2659f33e4495f6d314)

diff --git a/examples/sqlite_remember_bot/src/transitions.rs b/examples/sqlite_remember_bot/src/transitions.rs
index dcc78db..c8f1777 100644
--- a/examples/sqlite_remember_bot/src/transitions.rs
+++ b/examples/sqlite_remember_bot/src/transitions.rs
@@ -21,6 +21,15 @@ async fn have_number(
     ans: String,
 ) -> TransitionOut<Dialogue> {
     let num = state.number;
+    match ans {
+        "abc" => {
+            match num {
+                1 => { cx.answer_str("hi"); }
+                _ => cx.answer_str("hi")
+            }
+        }
+        _ => ()
+    };
 
     if ans.starts_with("/get") {
         cx.answer_str(format!("Here is your number: {}", num)).await?;

Meta

It fails on stable and nightly:

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.49.0 (e1884a8 2020-12-29)
binary: rustc
commit-hash: e1884a8
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0

and

rustc 1.51.0-nightly (04caa63 2021-01-30)
binary: rustc
commit-hash: 04caa63
commit-date: 2021-01-30
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

<version>

Error output

From stable, non verbose:

error[E0308]: mismatched types
  --> src/transitions.rs:25:9
   |
24 |     match ans {
   |           --- this expression has type `std::string::String`
25 |         "abc" => {
   |         ^^^^^ expected struct `std::string::String`, found `&str`

thread 'rustc' panicked at 'DefId::expect_local: `DefId(22:1034 ~ teloxide[eccd]::dispatching::update_with_cx::{impl#1}::answer_str::{opaque#0})` isn't local', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/compiler/rustc_span/src/def_id.rs:175:43
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.49.0 (e1884a8e3 2020-12-29) 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 `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
#1 [mir_built] building MIR for `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sqlite_remember_bot`

Backtrace

error[E0308]: mismatched types
  --> src/transitions.rs:25:9
   |
24 |     match ans {
   |           --- this expression has type `std::string::String`
25 |         "abc" => {
   |         ^^^^^ expected struct `std::string::String`, found `&str`

thread 'rustc' panicked at 'DefId::expect_local: `DefId(22:1034 ~ teloxide[eccd]::dispatching::update_with_cx::{impl#1}::answer_str::{opaque#0})` isn't local', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/compiler/rustc_span/src/def_id.rs:175:43
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: std::panicking::begin_panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:437:5
   2: rustc_span::def_id::DefId::expect_local::{{closure}}
   3: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::could_remove_semicolon
   4: rustc_typeck::check::_match::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
   5: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
   6: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
   7: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
   8: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
   9: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  10: rustc_typeck::check::_match::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  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::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  14: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  15: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  16: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  17: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  18: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  19: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  23: rustc_typeck::check::check::check_fn
  24: rustc_typeck::check::closure::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_closure
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  26: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  27: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
  28: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  29: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  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::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  33: rustc_typeck::check::check::check_fn
  34: rustc_infer::infer::InferCtxtBuilder::enter
  35: rustc_typeck::check::typeck
  36: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_middle::ty::context::TyCtxt::typeck_opt_const_arg
  41: rustc_mir_build::thir::cx::Cx::new
  42: rustc_infer::infer::InferCtxtBuilder::enter
  43: rustc_mir_build::build::mir_built
  44: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_built>::compute
  45: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  46: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  47: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  48: rustc_query_system::query::plumbing::get_query_impl
  49: rustc_mir::transform::check_unsafety::unsafety_check_result
  50: core::ops::function::FnOnce::call_once
  51: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  52: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  53: rustc_data_structures::stack::ensure_sufficient_stack
  54: rustc_query_system::query::plumbing::force_query_impl
  55: rustc_middle::ty::query::force_from_dep_node
  56: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  57: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  58: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  59: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_green_and_read
  60: rustc_data_structures::stack::ensure_sufficient_stack
  61: rustc_query_system::query::plumbing::get_query_impl
  62: rustc_typeck::collect::type_of::type_of
  63: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute
  64: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  65: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  66: rustc_data_structures::stack::ensure_sufficient_stack
  67: rustc_query_system::query::plumbing::get_query_impl
  68: rustc_typeck::check::check::check_item_type
  69: rustc_middle::hir::map::Map::visit_item_likes_in_module
  70: rustc_typeck::check::check::check_mod_item_types
  71: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute
  72: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  73: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  74: rustc_data_structures::stack::ensure_sufficient_stack
  75: rustc_query_system::query::plumbing::get_query_impl
  76: rustc_query_system::query::plumbing::ensure_query_impl
  77: rustc_session::utils::<impl rustc_session::session::Session>::time
  78: rustc_typeck::check_crate
  79: rustc_interface::passes::analysis
  80: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  81: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  82: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  83: rustc_data_structures::stack::ensure_sufficient_stack
  84: rustc_query_system::query::plumbing::get_query_impl
  85: rustc_interface::passes::QueryContext::enter
  86: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  87: rustc_span::with_source_map
  88: rustc_interface::interface::create_compiler_and_run
  89: rustc_span::with_session_globals
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.49.0 (e1884a8e3 2020-12-29) 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 `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
#1 [mir_built] building MIR for `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
#2 [unsafety_check_result] unsafety-checking `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
#3 [mir_borrowck] borrow-checking `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number`
#4 [type_of] computing type of `transitions::<impl teloxide::dispatching::dialogue::Subtransition for states::HaveNumberState>::react::have_number::{opaque#0}`
#5 [check_mod_item_types] checking item types in module `transitions`
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sqlite_remember_bot`

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-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