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

ICE checking rustc_middle with debug_assertions enabled #10253

Closed
albertlarsan68 opened this issue Jan 29, 2023 · 9 comments · Fixed by #11259
Closed

ICE checking rustc_middle with debug_assertions enabled #10253

albertlarsan68 opened this issue Jan 29, 2023 · 9 comments · Fixed by #11259
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@albertlarsan68
Copy link
Member

albertlarsan68 commented Jan 29, 2023

Summary

Running x clippy rustc_middle --stage 1 -Awarnings when having the tip of rust-lang/rust#106394 checked out (last verified on rust-lang/rust@0bb3f5b) ICEs when checking rustc_middle.
It only happens when debug assertiaons are enabled.
It is definitely due to clippy.
Here is the error:

 thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `(1, Some(1))`,
 right: `(2, Some(2))`: wrong number of generic parameters for DefId(2:7162 ~ core[0bcc]::iter::traits::iterator::Iterator): [&mut mir::traversal::Preorder<'_, '_>, fn((mir::BasicBlock, &mir::BasicBlockData<'_>)) {std::mem::drop::<(mir::BasicBlock, &mir::BasicBlockData<'_>)>}]', /home/gh-albertlarsan68/rust/compiler/rustc_middle/src/ty/context.rs:1762:13

cc @jyn514

Version

in-tree clippy at 0bb3f5b0a9915f00cbabb11549126ee92296f7ac

Error output

Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `(1, Some(1))`,
right: `(2, Some(2))`: wrong number of generic parameters for DefId(2:7162 ~ core[0bcc]::iter::traits::iterator::Iterator): [&mut mir::traversal::Preorder<'_, '_>, fn((mir::BasicBlock, &mir::BasicBlockData<'_>)) {std::mem::drop::<(mir::BasicBlock, &mir::BasicBlockData<'_>)>}]', /home/gh-albertlarsan68/rust/compiler/rustc_middle/src/ty/context.rs:1762:13
stack backtrace:
 0: rust_begin_unwind
           at ./library/std/src/panicking.rs:575:5
 1: core::panicking::panic_fmt
           at ./library/core/src/panicking.rs:64:14
 2: core::panicking::assert_failed_inner
 3: core::panicking::assert_failed::<(usize, core::option::Option<usize>), (usize, core::option::Option<usize>)>
           at ./library/core/src/panicking.rs:212:5
 4: <rustc_middle::ty::context::TyCtxt>::check_substs::<rustc_middle::ty::subst::GenericArg, core::iter::adapters::chain::Chain<core::array::iter::IntoIter<rustc_middle::ty::subst::GenericArg, 1>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::subst::GenericArg>>>>
           at ./compiler/rustc_middle/src/ty/context.rs:1762:13
 5: <rustc_middle::ty::context::TyCtxt>::mk_trait_ref::<rustc_middle::ty::subst::GenericArg, core::iter::adapters::chain::Chain<core::array::iter::IntoIter<rustc_middle::ty::subst::GenericArg, 1>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::subst::GenericArg>>>>
           at ./compiler/rustc_middle/src/ty/context.rs:2066:22
 6: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::type_implements_trait::<rustc_middle::ty::subst::GenericArg, core::iter::adapters::chain::Chain<core::array::iter::IntoIter<rustc_middle::ty::subst::GenericArg, 1>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::subst::GenericArg>>>>::{closure#0}
           at ./compiler/rustc_trait_selection/src/infer.rs:88:25
 7: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::type_implements_trait::<rustc_middle::ty::subst::GenericArg, core::iter::adapters::chain::Chain<core::array::iter::IntoIter<rustc_middle::ty::subst::GenericArg, 1>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::subst::GenericArg>>>>
           at ./compiler/rustc_trait_selection/src/infer.rs:87:35
 8: clippy_lints::dereference::walk_parents::{closure#0}
           at ./src/tools/clippy/clippy_lints/src/dereference.rs:869:32
 9: <&mut clippy_lints::dereference::walk_parents::{closure#0} as core::ops::function::FnMut<(rustc_hir::hir::Node, rustc_hir::hir_id::HirId)>>::call_mut
           at ./library/core/src/ops/function.rs:298:13
10: clippy_utils::walk_to_expr_usage::<clippy_lints::dereference::Position, &mut clippy_lints::dereference::walk_parents::{closure#0}>
           at ./src/tools/clippy/clippy_utils/src/lib.rs:2427:26
11: clippy_lints::dereference::walk_parents
           at ./src/tools/clippy/clippy_lints/src/dereference.rs:711:20
12: <clippy_lints::dereference::Dereferencing as rustc_lint::passes::LateLintPass>::check_expr
           at ./src/tools/clippy/clippy_lints/src/dereference.rs:289:47
13: <rustc_lint::late::RuntimeCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_expr
           at ./compiler/rustc_lint/src/late.rs:325:21
14: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:161:13
15: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
16: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr
           at ./compiler/rustc_lint/src/late.rs:160:9
17: rustc_hir::intravisit::walk_expr::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:708:13
18: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:162:13
19: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
20: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr
           at ./compiler/rustc_lint/src/late.rs:160:9
21: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_stmt
           at ./compiler/rustc_lint/src/late.rs:173:9
22: rustc_hir::intravisit::walk_block::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:596:5
23: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_block
           at ./compiler/rustc_lint/src/late.rs:238:9
24: rustc_hir::intravisit::walk_expr::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:756:13
25: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:162:13
26: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
27: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr
           at ./compiler/rustc_lint/src/late.rs:160:9
28: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_body
           at ./compiler/rustc_lint/src/late.rs:124:9
29: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_body
           at ./compiler/rustc_lint/src/late.rs:107:9
30: rustc_hir::intravisit::walk_fn::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:934:5
31: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_fn
           at ./compiler/rustc_lint/src/late.rs:190:9
32: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:474:13
33: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:136:17
34: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_param_env::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:75:9
35: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:134:13
36: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
37: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item
           at ./compiler/rustc_lint/src/late.rs:133:9
38: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
           at ./compiler/rustc_hir/src/intravisit.rs:239:13
39: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:561:9
40: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::process_mod
           at ./compiler/rustc_lint/src/late.rs:81:9
41: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_mod
           at ./compiler/rustc_lint/src/late.rs:225:13
42: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:487:13
43: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:136:17
44: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_param_env::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:75:9
45: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:134:13
46: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
47: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item
           at ./compiler/rustc_lint/src/late.rs:133:9
48: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
           at ./compiler/rustc_hir/src/intravisit.rs:239:13
49: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:561:9
50: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::process_mod
           at ./compiler/rustc_lint/src/late.rs:81:9
51: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_mod
           at ./compiler/rustc_lint/src/late.rs:225:13
52: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:487:13
53: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:136:17
54: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_param_env::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:75:9
55: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:134:13
56: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
57: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_item
           at ./compiler/rustc_lint/src/late.rs:133:9
58: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
           at ./compiler/rustc_hir/src/intravisit.rs:239:13
59: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
           at ./compiler/rustc_hir/src/intravisit.rs:561:9
60: rustc_lint::late::late_lint_crate_inner::<rustc_lint::late::RuntimeCombinedLateLintPass>::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:423:9
61: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<rustc_lint::late::late_lint_crate_inner<rustc_lint::late::RuntimeCombinedLateLintPass>::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:63:9
62: rustc_lint::late::late_lint_crate_inner::<rustc_lint::late::RuntimeCombinedLateLintPass>
           at ./compiler/rustc_lint/src/late.rs:419:5
63: rustc_lint::late::late_lint_crate::<rustc_lint::BuiltinCombinedLateLintPass>
           at ./compiler/rustc_lint/src/late.rs:407:9
64: rustc_lint::late::check_crate::<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:438:17
65: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
           at ./compiler/rustc_data_structures/src/profiling.rs:723:9
66: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
           at ./compiler/rustc_session/src/utils.rs:10:9
67: rustc_lint::late::check_crate::<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}
           at ./compiler/rustc_lint/src/late.rs:436:13
68: rustc_data_structures::sync::join::<rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}, rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}, (), ()>
           at ./compiler/rustc_data_structures/src/sync.rs:117:14
69: rustc_lint::late::check_crate::<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>
           at ./compiler/rustc_lint/src/late.rs:434:5
70: rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}
           at ./compiler/rustc_interface/src/passes.rs:931:29
71: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<(), rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}>
           at ./compiler/rustc_data_structures/src/profiling.rs:723:9
72: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}::{closure#0}>
           at ./compiler/rustc_session/src/utils.rs:10:9
73: rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}
           at ./compiler/rustc_interface/src/passes.rs:930:25
74: <rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2} as core::ops::function::FnOnce<()>>::call_once
           at ./library/core/src/ops/function.rs:250:5
75: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}> as core::ops::function::FnOnce<()>>::call_once
           at ./library/core/src/panic/unwind_safe.rs:271:9
76: std::panicking::try::do_call::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}>, ()>
           at ./library/std/src/panicking.rs:483:40
77: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}>>
           at ./library/std/src/panicking.rs:447:19
78: std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#2}>, ()>
           at ./library/std/src/panic.rs:140:14
79: rustc_interface::passes::analysis::{closure#6}::{closure#1}
           at ./compiler/rustc_interface/src/passes.rs:921:17
80: <rustc_interface::passes::analysis::{closure#6}::{closure#1} as core::ops::function::FnOnce<()>>::call_once
           at ./library/core/src/ops/function.rs:250:5
81: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
           at ./library/core/src/panic/unwind_safe.rs:271:9
82: std::panicking::try::do_call::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}>, ()>
           at ./library/std/src/panicking.rs:483:40
83: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}>>
           at ./library/std/src/panicking.rs:447:19
84: std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}>, ()>
           at ./library/std/src/panic.rs:140:14
85: rustc_interface::passes::analysis::{closure#6}
           at ./compiler/rustc_interface/src/passes.rs:917:9
86: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<(), rustc_interface::passes::analysis::{closure#6}>
           at ./compiler/rustc_data_structures/src/profiling.rs:723:9
87: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}>
           at ./compiler/rustc_session/src/utils.rs:10:9
88: rustc_interface::passes::analysis
           at ./compiler/rustc_interface/src/passes.rs:916:5
89: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_query_system/src/dep_graph/graph.rs:340:53
90: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}
           at ./compiler/rustc_middle/src/dep_graph/mod.rs:58:46
91: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:38
92: rustc_middle::ty::context::tls::tlv::with_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:95:9
93: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:5
94: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_middle/src/dep_graph/mod.rs:58:13
95: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:143:36
96: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:132:18
97: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:143:5
98: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/dep_graph/mod.rs:55:9
99: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_query_system/src/dep_graph/graph.rs:340:22
100: <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>>
           at ./compiler/rustc_query_system/src/dep_graph/graph.rs:290:13
101: rustc_query_system::query::plumbing::execute_job::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}
           at ./compiler/rustc_query_system/src/query/plumbing.rs:470:13
102: stacker::maybe_grow::<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>
           at /home/gh-albertlarsan68/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.15/src/lib.rs:55:9
103: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>
           at ./compiler/rustc_data_structures/src/stack.rs:17:5
104: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}::{closure#0}
           at ./compiler/rustc_query_impl/src/plumbing.rs:128:17
105: rustc_middle::ty::context::tls::enter_context::<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:38
106: rustc_middle::ty::context::tls::tlv::with_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:95:9
107: rustc_middle::ty::context::tls::enter_context::<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:5
108: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}
           at ./compiler/rustc_query_impl/src/plumbing.rs:127:13
109: rustc_middle::ty::context::tls::with_related_context::<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:165:9
110: rustc_middle::ty::context::tls::with_context::<rustc_middle::ty::context::tls::with_related_context<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:143:36
111: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_context<rustc_middle::ty::context::tls::with_related_context<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:132:18
112: rustc_middle::ty::context::tls::with_context::<rustc_middle::ty::context::tls::with_related_context<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:143:5
113: rustc_middle::ty::context::tls::with_related_context::<<rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>::{closure#0}, (core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:156:5
114: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::<(core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#3}>
           at ./compiler/rustc_query_impl/src/plumbing.rs:112:9
115: rustc_query_system::query::plumbing::execute_job::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
           at ./compiler/rustc_query_system/src/query/plumbing.rs:458:9
116: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
           at ./compiler/rustc_query_system/src/query/plumbing.rs:378:17
117: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt, rustc_middle::dep_graph::dep_node::DepKind>
           at ./compiler/rustc_query_system/src/query/plumbing.rs:750:36
118: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis::{closure#0}
           at ./compiler/rustc_query_impl/src/plumbing.rs:727:17
119: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
           at ./compiler/rustc_query_impl/src/lib.rs:44:1
120: <rustc_middle::ty::query::TyCtxtAt>::analysis
           at ./compiler/rustc_middle/src/ty/query.rs:264:17
121: <rustc_middle::ty::context::TyCtxt>::analysis
           at ./compiler/rustc_middle/src/ty/query.rs:245:17
122: rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}
           at ./compiler/rustc_driver/src/lib.rs:350:30
123: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_interface/src/passes.rs:753:42
124: rustc_middle::ty::context::tls::enter_context::<<rustc_interface::passes::QueryContext>::enter<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:38
125: rustc_middle::ty::context::tls::tlv::with_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_interface::passes::QueryContext>::enter<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:95:9
126: rustc_middle::ty::context::tls::enter_context::<<rustc_interface::passes::QueryContext>::enter<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_middle/src/ty/context/tls.rs:115:5
127: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
           at ./compiler/rustc_interface/src/passes.rs:753:9
128: rustc_driver::run_compiler::{closure#1}::{closure#2}
           at ./compiler/rustc_driver/src/lib.rs:349:13
129: <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>>
           at ./compiler/rustc_interface/src/queries.rs:386:19
131: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}
           at ./compiler/rustc_interface/src/interface.rs:300:21
132: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
           at ./compiler/rustc_span/src/lib.rs:1026:5
133: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}
           at ./compiler/rustc_interface/src/interface.rs:294:13
134: <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>>
           at /home/gh-albertlarsan68/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
135: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
           at ./compiler/rustc_span/src/lib.rs:111:5
136: rustc_interface::util::run_in_thread_pool_with_globals::<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>>::{closure#0}::{closure#0}
           at ./compiler/rustc_interface/src/util.rs:146:38

@albertlarsan68 albertlarsan68 added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 29, 2023
@jyn514
Copy link
Member

jyn514 commented Jan 30, 2023

This is the relevant part of rustc_middle which causes the panic: https://github.com/rust-lang/rust/blob/a6235a2006edf09e6eb30bac04f33eef0d2744d1/compiler/rustc_middle/src/mir/traversal.rs#L48-L49
and this is the relevant part of clippy which is panicking: https://github.com/rust-lang/rust/blob/15d6325747d9e37b5e8f19718eada0d5307fdef2/src/tools/clippy/clippy_lints/src/dereference.rs#L872
cc @oli-obk, I think you were the last person to touch this in rust-lang/rust@595ae83.

Note that 0bb3f5b0a9915f00cbabb11549126ee92296f7ac has some changes to clippy, but I don't think they could cause this ICE: they only affect the sysroot flags and whether clippy runs on build scripts and proc-macros.

@jyn514
Copy link
Member

jyn514 commented Jan 30, 2023

This affects the EXPLICIT_DEREF_METHODS, NEEDLESS_BORROW, REF_BINDING_TO_REFERENCE, and EXPLICIT_AUTO_DEREF lints.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 30, 2023

Clippy is fetching the substs of a method in https://github.com/rust-lang/rust/blob/f55b0022db8dccc6aa6bf3f650b562eaec0fdc54/src/tools/clippy/clippy_lints/src/dereference.rs#L858 and then uses those substs as the substs of the trait. In that case it is entirely correct to ask the trait for how many generic parameters it has and only use the first that many entries in the method substs. You can get the number of generic parameters via generics_of(trait_def_id).count()

@oli-obk
Copy link
Contributor

oli-obk commented Jan 30, 2023

cc @oli-obk, I think you were the last person to touch this in rust-lang/rust@595ae83.

yea, I didn't change behaviour there, but I added the assert that is now being triggered.

@matthiaskrgr
Copy link
Member

this is still a problem 🙃

@oli-obk
Copy link
Contributor

oli-obk commented Jul 26, 2023

Maybe a minimization could help here, as it can then be tested in the clippy repo. This issue is not rustc_middle specific, that's just a huge crate with lots of weird shenanigans. The ICEs could happen anywhere in stable code, too

@y21
Copy link
Member

y21 commented Jul 26, 2023

I think I got a minimized test case, but I'm not sure if this can easily be tested from clippy's side. This ICE happens in a function in rustc_middle in a block that is cfg'd out unless rustc is compiled with debug assertions, so clippy presumably needs a rustc build with debug assertions to even get this to ICE I guess?
https://github.com/rust-lang/rust/blob/6908c73ab0a440dc47a65b19edd2d013aeb48c15/compiler/rustc_middle/src/ty/context.rs#L1630

Afaik clippy relies on the rustc-dev rustup component for calling into the rustc crates, and I don't think there's a way to get that with debug-assertions enabled (someone correct me if im wrong)? Anyway, here's what I think should reproduce the ICE:

struct S;
trait X {
  fn f<T>(&self);
}
impl X for &S {
  fn f<T>(&self) {}
}
fn main() {
  (&S).f::<()>();
}
thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `(1, Some(1))`,
 right: `(2, Some(2))`: wrong number of generic parameters for DefId(0:5 ~ test2[ab50]::X): [&S, ()]', clippy_lints/src/dereference.rs:470:33

(I tested this by copy-pasting the assertion from the relevant rustc_middle code into the clippy lint, hopefully this didn't miss out on some important detail).

@oli-obk
Copy link
Contributor

oli-obk commented Jul 26, 2023

clippy presumably needs a rustc build with debug assertions to even get this to ICE I guess?

Oof yea

It is essentially what x test clippy will do, so it would get some testing. I guess this is one case where you need to fix it in clippy within the rustc repo and land it there?

That does explain why we never saw it in the wild.

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jul 26, 2023

Right yeah, I have a rustc build with debug assertions and when I x.py install that, make it the default toolchain and run x.py clippy on rustc, it will eventually crash, but you might have to run into other crashes/hangs as well that happen before that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants