rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.46k stars 1.55k forks source link

Crash #9730

Closed fenollp closed 2 years ago

fenollp commented 2 years ago
cargo clippy --locked --frozen --offline --all-targets --all-features -- -D warnings
note: Clippy version: clippy 0.1.64 (a55dd71 2022-09-19)
query stack during panic:
#0 [type_op_prove_predicate] evaluating `type_op_prove_predicate` `Canonical { max_universe: U0, variables: [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<ipam_models::schema::ips::table, diesel::query_builder::where_clause::WhereClause<diesel::expression::operators::Eq<ipam_models::schema::ips::columns::id, diesel::expression::bound::Bound<diesel::pg::types::sql_types::Uuid, &uuid::Uuid>>>, (diesel::query_builder::update_statement::changeset::Assign<ipam_models::schema::ips::columns::attached_resource_id, diesel::expression::bound::Bound<diesel::sql_types::Nullable<diesel::pg::types::sql_types::Uuid>, uuid::Uuid>>, diesel::query_builder::update_statement::changeset::Assign<ipam_models::schema::ips::columns::attached_resource_type, diesel::expression::bound::Bound<diesel::sql_types::Nullable<ipam_models::ip::db_enum_impl_IpResourceType::Ip_resource_type>, core::option::Option<ipam_models::ip::IpResourceType>>>, diesel::query_builder::update_statement::changeset::Assign<ipam_models::schema::ips::columns::updated_at, ipam_models::utils::functions::statement_timestamp>)> as diesel::query_builder::AsQuery>, polarity:Positive), []) } } }`
#1 [mir_borrowck] borrow-checking `core::ip::attach_ip::{closure#0}`
#2 [mir_borrowck] borrow-checking `core::ip::attach_ip`
#3 [type_of] computing type of `core::ip::attach_ip::{opaque#0}`
#4 [check_mod_item_types] checking item types in module `core::ip`
#5 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:23:85
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:48:5
   3: <rustc_metadata::creader::CStore as rustc_session::cstore::CrateStore>::def_path_hash_to_def_id
   4: <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
   5: rustc_query_impl::query_callbacks::adt_def::force_from_dep_node
   6: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
   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::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::infer::canonical::Canonical<rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>, core::result::Result<&rustc_middle::infer::canonical::Canonical<rustc_middle::infer::canonical::QueryResponse<()>>, rustc_middle::traits::query::NoSolution>>>
  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::type_check::type_check
  22: rustc_borrowck::nll::compute_regions
  23: rustc_borrowck::do_mir_borrowck
  24: rustc_borrowck::mir_borrowck
  25: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  26: <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>
  27: 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>>
  28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  29: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
  30: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
  31: rustc_borrowck::type_check::type_check
  32: rustc_borrowck::nll::compute_regions
  33: rustc_borrowck::do_mir_borrowck
  34: rustc_borrowck::mir_borrowck
  35: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  36: <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>
  37: 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>>
  38: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  39: rustc_typeck::collect::type_of::type_of
  40: <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::DefId, rustc_middle::ty::Ty>
  41: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
  42: rustc_typeck::check::check::check_mod_item_types
  43: <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, ()>
  44: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  45: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  46: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#6}>
  47: rustc_typeck::check_crate
  48: rustc_interface::passes::analysis
  49: <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>>
  50: 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>>>
  51: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  52: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  53: <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>>
  54: 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}>
  55: <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>>
kraktus commented 2 years ago

Thanks for the report, are you able to share the code that lead to the ICE?

llogiq commented 2 years ago

I don't see anything clippy-related in that stack trace. Do you also get the same error with cargo check instead of cargo clippy?

fenollp commented 2 years ago

I'd have to work on minimizing this code to be able to share it, it's not public code.

Indeed a cargo check does not produce this crash (and passes without issue).

Even worse, running this same command after wiping ./target/does not reproduce the issue.

llogiq commented 2 years ago

Ah, then it's likely some incremental compilation bug that is only exhibited by clippy.