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.32k stars 1.53k forks source link

ICE: forcing query with already existing `DepNode` #10298

Open kayabaNerve opened 1 year ago

kayabaNerve commented 1 year ago

Summary

https://github.com/serai-dex/serai/tree/97951e3f4fcef1be3ad1693228883fe9a2e3709b/processor is the crate which triggered this (and exact commit). While I do not have a MRE, I hope this either serves as an additional stack trace, or that the ~350 line file the backtrace specifies is sufficiently small/readable.

Even without a fix being made available, I'd greatly appreciate if the underlying problem was identified so I can workaround this.

Version

rustc 1.69.0-nightly (50d3ba5bc 2023-02-04)
binary: rustc
commit-hash: 50d3ba5bcbf5c7e13d4ce068d3339710701dd603
commit-date: 2023-02-04
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

Backtrace

``` thread 'rustc' panicked at 'forcing query with already existing `DepNode` - query-key: Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(OutlivesPredicate(D, ReStatic), []), Binder(OutlivesPredicate(C, ReStatic), [])], reveal: UserFacing, constness: NotConst }, value: Normalize { value: [async fn body@processor/src/signer.rs:152:26: 348:4] } } } - dep-node: type_op_normalize_ty(86d75000ed1273ab-8c7ffe51fbbef097)', /rustc/50d3ba5bcbf5c7e13d4ce068d3339710701dd603/compiler/rustc_query_system/src/dep_graph/graph.rs:316:9 stack backtrace: 0: rust_begin_unwind at /rustc/50d3ba5bcbf5c7e13d4ce068d3339710701dd603/library/std/src/panicking.rs:575:5 1: core::panicking::panic_fmt at /rustc/50d3ba5bcbf5c7e13d4ce068d3339710701dd603/library/core/src/panicking.rs:64:14 2: >::with_task::>>, core::result::Result<&rustc_middle::infer::canonical::Canonical>, rustc_middle::traits::query::NoSolution>> 3: rustc_query_system::query::plumbing::try_execute_query:: 4: ::type_op_normalize_ty 5: > as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform 6: <&mut ::create::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::Ty,)>>::call_once 7: as alloc::vec::spec_from_iter::SpecFromIter<&rustc_middle::infer::canonical::QueryRegionConstraints, core::iter::adapters::flatten::FlatMap>, core::option::IntoIter>, core::iter::adapters::chain::Chain, core::option::IntoIter<&rustc_middle::infer::canonical::QueryRegionConstraints>>, core::option::IntoIter<&rustc_middle::infer::canonical::QueryRegionConstraints>>, ::create::{closure#0}>>>::from_iter 8: rustc_borrowck::type_check::free_region_relations::create 9: rustc_borrowck::type_check::type_check 10: rustc_borrowck::nll::compute_regions 11: rustc_borrowck::do_mir_borrowck 12: rustc_borrowck::mir_borrowck 13: >::call_once 14: >::with_task:: 15: rustc_query_system::query::plumbing::try_execute_query:: 16: ::mir_borrowck 17: ::prove_closure_bounds 18: ::typeck_mir 19: rustc_borrowck::type_check::type_check 20: rustc_borrowck::nll::compute_regions 21: rustc_borrowck::do_mir_borrowck 22: rustc_borrowck::mir_borrowck 23: >::call_once 24: >::with_task:: 25: rustc_query_system::query::plumbing::try_execute_query:: 26: rustc_query_system::query::plumbing::force_query:: 27: rustc_query_impl::plumbing::force_from_dep_node:: 28: >::try_mark_previous_green:: 29: rustc_query_system::query::plumbing::get_query:: 30: rustc_hir_analysis::check::check::check_mod_item_types 31: >::with_task:: 32: rustc_query_system::query::plumbing::try_execute_query:: 33: ::check_mod_item_types 34: ::for_each_module:: 35: rustc_hir_analysis::check_crate 36: rustc_interface::passes::analysis 37: >::with_task::> 38: rustc_query_system::query::plumbing::try_execute_query:: 39: ::analysis 40: ::enter::> 41: ::enter::, rustc_errors::ErrorGuaranteed>> 42: rustc_span::with_source_map::, rustc_interface::interface::run_compiler, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 43: >::set::, rustc_driver_impl::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.69 (50d3ba5 2023-02-04) query stack during panic: #0 [type_op_normalize_ty] normalizing `[async fn body@processor/src/signer.rs:152:26: 348:4]` #1 [mir_borrowck] borrow-checking `signer::::run::{closure#0}` #2 [mir_borrowck] borrow-checking `signer::::run` #3 [type_of] computing type of `signer::::run::{opaque#0}` #4 [check_mod_item_types] checking item types in module `signer` #5 [analysis] running analysis passes on this crate end of query stack error: could not compile `processor` ```

kayabaNerve commented 1 year ago

It seems to be the lambda specified here: https://github.com/serai-dex/serai/blob/97951e3f4fcef1be3ad1693228883fe9a2e3709b/processor/src/signer.rs#L154-L159

Fully specifying it prevents this ICE from occurring.

I attempted to write a MRE premised on a similar pattern, yet was unable to get it to trigger.

langston-barrett commented 1 year ago

I'm not able to reproduce this. Here's what I tried:

git clone https://github.com/serai-dex/serai
cd serai/processor
rustup override set nightly
git checkout 97951e3f4fcef1be3ad1693228883fe9a2e3709b
cargo clippy
cargo clippy --release
clippy 0.1.70 (7b4f489 2023-03-12)

rustc 1.70.0-nightly (7b4f48927 2023-03-12)
binary: rustc
commit-hash: 7b4f48927dce585f747a58083b45ab62b9d73a53
commit-date: 2023-03-12
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7
kayabaNerve commented 1 year ago

It may no longer be an issue. I have not had this pop up over the past month (though that may just be since I patched the lambda to no longer trigger this).

The only note I'd make is I generally run --all-features --all-targets, in case that makes any difference with your reproduction attempts.

Thanks for spending the time. If it's not reproducible, I won't complain about closing this.

kangalio commented 1 year ago

I also ran into this

``` Checking poise v0.5.3 (/home/kangalio/dev/rust/poise) thread 'rustc' panicked at 'forcing query with already existing `DepNode` - query-key: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(ProjectionPredicate(AliasTy { substs: [impl for<'b> FnOnce(&'b mut crate::CreateReply<'att>) -> &'b mut crate::CreateReply<'att>, (&'b mut reply::builder::CreateReply<'_>,)], def_id: DefId(2:2940 ~ core[1d43]::ops::function::FnOnce::Output) }, Term::Ty(&'b mut reply::builder::CreateReply<'_>)), [Region(BrNamed(DefId(0:1909 ~ poise[298d]::structs::context::{impl#15}::send::'b), 'b))]), Binder(TraitPredicate( FnOnce(&'b mut crate::CreateReply<'att>) -> &'b mut crate::CreateReply<'att> as std::ops::FnOnce<(&'b mut reply::builder::CreateReply<'_>,)>>, polarity:Positive), [Region(BrNamed(DefId(0:1909 ~ poise[298d]::structs::context::{impl#15}::send::'b), 'b))]), Binder(TraitPredicate( FnOnce(&'b mut crate::CreateReply<'att>) -> &'b mut crate::CreateReply<'att> as std::marker::Sized>, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), []), Binder(TraitPredicate(, polarity:Positive), [])], reveal: UserFacing, constness: NotConst }, value: Normalize { value: [async fn body@src/structs/context.rs:59:22: 61:14] } } } - dep-node: type_op_normalize_ty(a3f5f0a56b8909be-e5edb6b394d64689)', /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/compiler/rustc_query_system/src/dep_graph/graph.rs:316:9 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.68 (9eb3afe 2023-03-27) query stack during panic: #0 [type_op_normalize_ty] normalizing `[async fn body@src/structs/context.rs:59:22: 61:14]` #1 [mir_borrowck] borrow-checking `structs::context::::send::{closure#0}` end of query stack error: could not compile `poise` ```

I considered zipping my project including target folder, but it's almost 15 GB (Cargo caching has dementia) so I decided against. cargo clean -p PROJECTNAME fixes the problem as expected