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

Bug "Failed to extract DefId" #9411

Open
jakob-lilliemarck opened this issue Sep 1, 2022 · 5 comments
Open

Bug "Failed to extract DefId" #9411

jakob-lilliemarck opened this issue Sep 1, 2022 · 5 comments

Comments

@jakob-lilliemarck
Copy link

Hey,
I got across this compiler error that asked me to post this bug - please let me know what other information you may need

thread 'rustc' panicked at 'Failed to extract DefId: local_def_id_to_hir_id a336cde79f85c510-9d1e316af452ad81', compiler/rustc_middle/src/dep_graph/dep_node.rs:276:17
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-clippy/issues/new

note: Clippy version: clippy 0.1.65 (9243168 2022-08-31)

query stack during panic:
#0 [type_op_prove_predicate] evaluating `type_op_prove_predicate` `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: ProvePredicate { predicate: Binder(TraitPredicate(<diesel::query_builder::update_statement::UpdateStatement<schema::script::table, diesel::query_builder::where_clause::WhereClause<diesel::expression::operators::Eq<schema::script::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, &i32>>>, (diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::name, diesel::expression::bound::Bound<diesel::sql_types::Text, &alloc::string::String>>, core::option::Option<diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::description, diesel::expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::Text>, &alloc::string::String>>>, diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::is_active, diesel::expression::bound::Bound<diesel::sql_types::Bool, &bool>>, core::option::Option<diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::owner_id, diesel::expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::Integer>, &i32>>>)> as diesel::query_builder::AsQuery>, polarity:Positive), []) } } }`
#1 [mir_borrowck] borrow-checking `adapters::script::<impl at sbox_pg/src/adapters/script.rs:12:1: 12:42>::update::{closure#0}`
end of query stack
@Jarcho
Copy link
Contributor

Jarcho commented Sep 1, 2022

This will need at least a backtrace.

@jakob-lilliemarck
Copy link
Author

Good morning, yes, sorry about that - this is my first time reporting a bug like this. I didn't notice the text in the message at first. Below is the output with backtrace.

If it's of any help - this issue happens after reverting a diesel migration, removing a column of a table from the migration file, and then running the migration again. If i put the column back in the migration, it ends up in the resulting schema.rs from diesel and all is fine again

thread 'rustc' panicked at 'Failed to extract DefId: local_def_id_to_hir_id f7d3bb99821d4358-4b031ed2ae1b2beb', compiler/rustc_middle/src/dep_graph/dep_node.rs:276:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9243168fa5615ec8ebe9164c6bc2fdcccffd08b6/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/9243168fa5615ec8ebe9164c6bc2fdcccffd08b6/library/core/src/panicking.rs:142:14
   2: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
   3: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   4: rustc_query_impl::query_callbacks::local_def_id_to_hir_id::force_from_dep_node
   5: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
   6: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   7: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  11: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  12: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  14: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_op_prove_predicate, rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_op_prove_predicate
  16: <rustc_middle::traits::query::type_op::ProvePredicate as rustc_trait_selection::traits::query::type_op::QueryTypeOp>::perform_query
  17: <rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
  18: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
  19: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
  20: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
  21: rustc_borrowck::nll::compute_regions
  22: rustc_borrowck::do_mir_borrowck
  23: rustc_borrowck::mir_borrowck
  24: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>
  26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>>
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  28: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
  29: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
  30: rustc_borrowck::nll::compute_regions
  31: rustc_borrowck::do_mir_borrowck
  32: rustc_borrowck::mir_borrowck
  33: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  34: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>
  35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>>
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  37: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  38: rustc_interface::passes::analysis
  39: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  40: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  41: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  42: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  43: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  44: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  45: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  46: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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-clippy/issues/new

note: Clippy version: clippy 0.1.65 (9243168 2022-08-31)

query stack during panic:
#0 [type_op_prove_predicate] evaluating `type_op_prove_predicate` `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: ProvePredicate { predicate: Binder(TraitPredicate(<diesel::query_builder::update_statement::UpdateStatement<schema::script::table, diesel::query_builder::where_clause::WhereClause<diesel::expression::operators::Eq<schema::script::columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, &i32>>>, (diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::name, diesel::expression::bound::Bound<diesel::sql_types::Text, &alloc::string::String>>, core::option::Option<diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::description, diesel::expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::Text>, &alloc::string::String>>>, diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::is_active, diesel::expression::bound::Bound<diesel::sql_types::Bool, &bool>>, core::option::Option<diesel::query_builder::update_statement::changeset::Assign<schema::script::columns::owner_id, diesel::expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::Integer>, &i32>>>)> as diesel::query_builder::AsQuery>, polarity:Positive), []) } } }`
#1 [mir_borrowck] borrow-checking `adapters::script::<impl at sbox_pg/src/adapters/script.rs:12:1: 12:42>::update::{closure#0}`
#2 [mir_borrowck] borrow-checking `adapters::script::<impl at sbox_pg/src/adapters/script.rs:12:1: 12:42>::update`
#3 [analysis] running analysis passes on this crate
end of query stack

@Jarcho
Copy link
Contributor

Jarcho commented Sep 2, 2022

It's possibly an incremental compilation bug. You can see if it works after running cargo clean.

@jakob-lilliemarck
Copy link
Author

That seems correct, after running cargo clean it magically compiles again. Before we close this I'd like to ask what parts of the log made you realize it's an "incremental compilation bug"? Would be great to know what to look for
Many thanks!

@Jarcho
Copy link
Contributor

Jarcho commented Sep 6, 2022

A few things:

  • The crash is during the analysis phase, which is before clippy runs.
  • local_def_id_to_hir_id shouldn't fail. LocalDefIds are created from HirIds, or loaded from cache.
  • incremental compilation bugs are a frequent source of crashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants