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 unexpected sort of node in fn_sig(): Item(Item..` #11065

Closed
matthiaskrgr opened this issue Jul 2, 2023 · 2 comments · Fixed by #11070
Closed

ice unexpected sort of node in fn_sig(): Item(Item..` #11065

matthiaskrgr opened this issue Jul 2, 2023 · 2 comments · Fixed by #11070
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jul 2, 2023

Summary

use std::iter::FromIterator;
use std::option::IntoIter as OptionIter;

fn eq<T: Eq>(a: T, b: T) -> bool { a == b }


macro_rules! tests {
    ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
        const C: $ty = $expr;
        assert!(eq(C($($test),*), $expr($($test),*)));
    })+})
}

tests! {
    FromIterator::from_iter, fn(OptionIter<i32>) -> Vec<i32>, (Some(5).into_iter());
}

Version

rustc 1.72.0-nightly (32d81eccd 2023-07-02)
binary: rustc
commit-hash: 32d81eccd64513bacef9dfa1574543ada6b45d85
commit-date: 2023-07-02
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

Backtrace

error: internal compiler error: compiler/rustc_hir_analysis/src/collect.rs:1175:13: unexpected sort of node in fn_sig(): Item(Item { ident: C#4, owner_id: DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C), kind: Const(Ty { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).9), kind: BareFn(BareFnTy { unsafety: Normal, abi: Rust, generic_params: [], decl: FnDecl { inputs: [Ty { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).1), kind: Path(Resolved(None, Path { span: ufcs-polymorphic-paths.rs:17:33: 17:48 (#0), res: Def(Struct, DefId(2:41611 ~ core[0662]::option::IntoIter)), segments: [PathSegment { ident: OptionIter#0, hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).4), res: Def(Struct, DefId(2:41611 ~ core[0662]::option::IntoIter)), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).2), kind: Path(Resolved(None, Path { span: ufcs-polymorphic-paths.rs:17:44: 17:47 (#0), res: PrimTy(Int(I32)), segments: [PathSegment { ident: i32#0, hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).3), res: PrimTy(Int(I32)), args: None, infer_args: false }] })), span: ufcs-polymorphic-paths.rs:17:44: 17:47 (#0) })], bindings: [], parenthesized: No, span_ext: ufcs-polymorphic-paths.rs:17:43: 17:48 (#0) }), infer_args: false }] })), span: ufcs-polymorphic-paths.rs:17:33: 17:48 (#0) }], output: Return(Ty { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).5), kind: Path(Resolved(None, Path { span: ufcs-polymorphic-paths.rs:17:53: 17:61 (#0), res: Def(Struct, DefId(5:6719 ~ alloc[6729]::vec::Vec)), segments: [PathSegment { ident: Vec#0, hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).8), res: Def(Struct, DefId(5:6719 ~ alloc[6729]::vec::Vec)), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).6), kind: Path(Resolved(None, Path { span: ufcs-polymorphic-paths.rs:17:57: 17:60 (#0), res: PrimTy(Int(I32)), segments: [PathSegment { ident: i32#0, hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).7), res: PrimTy(Int(I32)), args: None, infer_args: false }] })), span: ufcs-polymorphic-paths.rs:17:57: 17:60 (#0) })], bindings: [], parenthesized: No, span_ext: ufcs-polymorphic-paths.rs:17:56: 17:61 (#0) }), infer_args: false }] })), span: ufcs-polymorphic-paths.rs:17:53: 17:61 (#0) }), c_variadic: false, implicit_self: None, lifetime_elision_allowed: false }, param_names: [#0] }), span: ufcs-polymorphic-paths.rs:17:30: 17:61 (#0) }, BodyId { hir_id: HirId(DefId(0:9 ~ ufcs_polymorphic_paths[8e59]::main::C).10) }), span: ufcs-polymorphic-paths.rs:11:9: 11:30 (#4), vis_span: ufcs-polymorphic-paths.rs:11:9: 11:9 (#4) })

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/compiler/rustc_errors/src/lib.rs:1650:9
stack backtrace:
 0:     0x7f9f0edf4e31 - std::backtrace_rs::backtrace::libunwind::trace::h1aa701a6f07f9bbb
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7f9f0edf4e31 - std::backtrace_rs::backtrace::trace_unsynchronized::h9ae9d6e8c5c72b62
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7f9f0edf4e31 - std::sys_common::backtrace::_print_fmt::hfaef5052365cf665
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:65:5
 3:     0x7f9f0edf4e31 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haeef210b4538668a
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7f9f0ee565df - core::fmt::rt::Argument::fmt::h33bbbf421d58fca4
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/fmt/rt.rs:138:9
 5:     0x7f9f0ee565df - core::fmt::write::he44b856c4b45f787
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/fmt/mod.rs:1094:21
 6:     0x7f9f0ede7967 - std::io::Write::write_fmt::hded42ab4301c934e
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/io/mod.rs:1714:15
 7:     0x7f9f0edf4c45 - std::sys_common::backtrace::_print::h12bd163b4566637e
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7f9f0edf4c45 - std::sys_common::backtrace::print::h78df3905035fd00a
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7f9f0edf79f3 - std::panicking::default_hook::{{closure}}::h588795889886bd81
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:269:22
10:     0x7f9f0edf7784 - std::panicking::default_hook::h8f33142631f33dcd
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:288:9
11:     0x7f9f0dc0da9b - <rustc_driver_impl[aedb6f0638cc4997]::install_ice_hook::{closure#0} as core[66236b962f4f8b3]::ops::function::FnOnce<(&core[66236b962f4f8b3]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
12:     0x7f9f0edf821e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3d4c5f73aa534950
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2024:9
13:     0x7f9f0edf821e - std::panicking::rust_panic_with_hook::hf8beb94f0fe0d1f3
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:709:13
14:     0x7f9f0e1b9a31 - std[d57842597b9c3de2]::panicking::begin_panic::<rustc_errors[9487b0fe91249864]::ExplicitBug>::{closure#0}
15:     0x7f9f0e1b9546 - std[d57842597b9c3de2]::sys_common::backtrace::__rust_end_short_backtrace::<std[d57842597b9c3de2]::panicking::begin_panic<rustc_errors[9487b0fe91249864]::ExplicitBug>::{closure#0}, !>
16:     0x7f9f0e19a596 - std[d57842597b9c3de2]::panicking::begin_panic::<rustc_errors[9487b0fe91249864]::ExplicitBug>
17:     0x7f9f0e1324c4 - <rustc_errors[9487b0fe91249864]::HandlerInner>::bug::<alloc[67293afed414a74a]::string::String>
18:     0x7f9f0e132346 - <rustc_errors[9487b0fe91249864]::Handler>::bug::<alloc[67293afed414a74a]::string::String>
19:     0x7f9f0e10058c - rustc_middle[b999effd84d4d25b]::util::bug::opt_span_bug_fmt::<rustc_span[175a833f7d8153f1]::span_encoding::Span>::{closure#0}
20:     0x7f9f0e1002ea - rustc_middle[b999effd84d4d25b]::ty::context::tls::with_opt::<rustc_middle[b999effd84d4d25b]::util::bug::opt_span_bug_fmt<rustc_span[175a833f7d8153f1]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21:     0x7f9f0e1002ba - rustc_middle[b999effd84d4d25b]::ty::context::tls::with_context_opt::<rustc_middle[b999effd84d4d25b]::ty::context::tls::with_opt<rustc_middle[b999effd84d4d25b]::util::bug::opt_span_bug_fmt<rustc_span[175a833f7d8153f1]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22:     0x7f9f0c38e8ad - rustc_middle[b999effd84d4d25b]::util::bug::bug_fmt
23:     0x7f9f0c104cad - rustc_hir_analysis[2ab22ce4e0abfec2]::collect::fn_sig
24:     0x7f9f0c1046bc - rustc_query_impl[b332ceb5079bcc8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b332ceb5079bcc8]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 24usize]>>
25:     0x7f9f0c104675 - <rustc_query_impl[b332ceb5079bcc8]::query_impl::fn_sig::dynamic_query::{closure#2} as core[66236b962f4f8b3]::ops::function::FnOnce<(rustc_middle[b999effd84d4d25b]::ty::context::TyCtxt, rustc_span[175a833f7d8153f1]::def_id::DefId)>>::call_once
26:     0x7f9f0bcffa48 - rustc_query_system[16e9793ec34b9d59]::query::plumbing::try_execute_query::<rustc_query_impl[b332ceb5079bcc8]::DynamicConfig<rustc_query_system[16e9793ec34b9d59]::query::caches::DefaultCache<rustc_span[175a833f7d8153f1]::def_id::DefId, rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[b332ceb5079bcc8]::plumbing::QueryCtxt, false>
27:     0x7f9f0d5aecb4 - rustc_query_impl[b332ceb5079bcc8]::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
28:     0x55965374fac1 - rustc_middle[b999effd84d4d25b]::query::plumbing::query_get_at::<rustc_query_system[16e9793ec34b9d59]::query::caches::DefaultCache<rustc_span[175a833f7d8153f1]::def_id::DefId, rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 24usize]>>>
29:     0x559653771bad - <clippy_lints[9f662dfa9206825f]::useless_conversion::UselessConversion as rustc_lint[e2531b73e1252f52]::passes::LateLintPass>::check_expr
30:     0x7f9f0e044e66 - <rustc_lint[e2531b73e1252f52]::early::RuntimeCombinedEarlyLintPass as rustc_lint[e2531b73e1252f52]::passes::EarlyLintPass>::check_generic_arg
31:     0x7f9f0dfdf6c6 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
32:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
33:     0x7f9f0dfb04e8 - rustc_hir[7da11ae52209a363]::intravisit::walk_expr::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
34:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
35:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
36:     0x7f9f0dfb04e8 - rustc_hir[7da11ae52209a363]::intravisit::walk_expr::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
37:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
38:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
39:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
40:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
41:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
42:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
43:     0x7f9f0dfb058e - rustc_hir[7da11ae52209a363]::intravisit::walk_expr::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
44:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
45:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
46:     0x7f9f0dfaeeab - rustc_hir[7da11ae52209a363]::intravisit::walk_block::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
47:     0x7f9f0dfe0099 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_block
48:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
49:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
50:     0x7f9f0dfe0099 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_block
51:     0x7f9f0dfdf6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
52:     0x7f9f0dfdff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
53:     0x7f9f0dfe03e5 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_nested_body
54:     0x7f9f0dfe05ca - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_fn
55:     0x7f9f0dfb0883 - rustc_hir[7da11ae52209a363]::intravisit::walk_item::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
56:     0x7f9f0dfe0d2f - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_nested_item
57:     0x7f9f0dfb0108 - rustc_hir[7da11ae52209a363]::intravisit::walk_mod::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
58:     0x7f9f0d08246e - rustc_lint[e2531b73e1252f52]::late::late_lint_crate::<rustc_lint[e2531b73e1252f52]::BuiltinCombinedLateLintPass>
59:     0x7f9f0d081888 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_lint[e2531b73e1252f52]::late::check_crate<rustc_lint[e2531b73e1252f52]::BuiltinCombinedLateLintPass, rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
60:     0x7f9f0d081723 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
61:     0x7f9f0d0812d9 - std[d57842597b9c3de2]::panicking::try::<(), core[66236b962f4f8b3]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}>>
62:     0x7f9f0d0806e0 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}>
63:     0x7f9f0d07e367 - rustc_interface[69a9f571ec0ef69d]::passes::analysis
64:     0x7f9f0d0fc8da - rustc_query_impl[b332ceb5079bcc8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 1usize]>>
65:     0x7f9f0d0fc8c9 - <rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::dynamic_query::{closure#2} as core[66236b962f4f8b3]::ops::function::FnOnce<(rustc_middle[b999effd84d4d25b]::ty::context::TyCtxt, ())>>::call_once
66:     0x7f9f0d29b758 - rustc_query_system[16e9793ec34b9d59]::query::plumbing::try_execute_query::<rustc_query_impl[b332ceb5079bcc8]::DynamicConfig<rustc_query_system[16e9793ec34b9d59]::query::caches::SingleCache<rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[b332ceb5079bcc8]::plumbing::QueryCtxt, false>
67:     0x7f9f0d29b529 - rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
68:     0x7f9f0ce8e735 - <rustc_middle[b999effd84d4d25b]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
69:     0x7f9f0ce8dd61 - <rustc_interface[69a9f571ec0ef69d]::interface::Compiler>::enter::<rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}::{closure#2}, core[66236b962f4f8b3]::result::Result<core[66236b962f4f8b3]::option::Option<rustc_interface[69a9f571ec0ef69d]::queries::Linker>, rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
70:     0x7f9f0ce84885 - rustc_span[175a833f7d8153f1]::set_source_map::<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
71:     0x7f9f0ce83ca6 - <scoped_tls[6271c32cbaced029]::ScopedKey<rustc_span[175a833f7d8153f1]::SessionGlobals>>::set::<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
72:     0x7f9f0ce83256 - std[d57842597b9c3de2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[69a9f571ec0ef69d]::util::run_in_thread_pool_with_globals<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
73:     0x7f9f0d49828e - <<std[d57842597b9c3de2]::thread::Builder>::spawn_unchecked_<rustc_interface[69a9f571ec0ef69d]::util::run_in_thread_pool_with_globals<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#1} as core[66236b962f4f8b3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
74:     0x7f9f0ee02695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h224d71f7c1e19ed0
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2010:9
75:     0x7f9f0ee02695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c133a1396147f3c
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2010:9
76:     0x7f9f0ee02695 - std::sys::unix::thread::Thread::new::thread_start::hb96c84e6fd62e1f0
                             at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys/unix/thread.rs:108:17
77:     0x7f9f0a75244b - <unknown>
78:     0x7f9f0a7d5e40 - <unknown>
79:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: rustc 1.72.0-nightly (32d81eccd 2023-07-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `main::C`
#1 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.72 (32d81ec 2023-07-02)

error: aborting due to previous error

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

y21 commented Jul 2, 2023

Smaller repro without the macros:

use std::option::IntoIter;

fn main() {
    const C: fn(IntoIter<i32>) -> IntoIter<i32> = <IntoIter<i32> as IntoIterator>::into_iter;
    C(Some(5).into_iter()); // ICE here
}

Seems like the useless_conversion lint assumes that since the parent expression of Some(5).into_iter() is a function call (C(...)), its path must point to an fn-like item, but here it does not. C is a const, but not a fn item, so fn_sig ICEs

@rustbot claim

@y21
Copy link
Member

y21 commented Jul 2, 2023

oh, hidden behind this ICE is also an FP.

It basically boils down to having a macro that expands an expr metavariable twice: once to trigger the lint, and again in a variable declaration with a type annotation, which would cause an error when removing the .into_iter(). Example:

use std::option::IntoIter;
fn takes_into_iter(_: impl IntoIterator<Item = i32>) {}

macro_rules! x {
    ($e:expr) => {
        takes_into_iter($e); // lint here because `.into_iter()` is "redundant"
        let _: IntoIter<i32> = $e; // removing `.into_iter()` leads to a type error here
    };
}

fn main() {
    x!(Some(5).into_iter());
}

I guess we shouldn't lint if the expression is not just from a macro expansion, but also part (i.e. an argument) of a macro call

@bors bors closed this as completed in 701e77c Aug 17, 2023
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 17, 2023
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes rust-lang#11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes rust-lang/rust-clippy#11065 (comment)).
It *also* makes sure that the expression is not part of a macro call (fixes rust-lang/rust-clippy#11065 (comment)). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed rust-lang#10814, which introduced these issues)
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 17, 2023
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes rust-lang#11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes rust-lang/rust-clippy#11065 (comment)).
It *also* makes sure that the expression is not part of a macro call (fixes rust-lang/rust-clippy#11065 (comment)). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed rust-lang#10814, which introduced these issues)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Aug 24, 2023
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes rust-lang#11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes rust-lang#11065 (comment)).
It *also* makes sure that the expression is not part of a macro call (fixes rust-lang#11065 (comment)). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed rust-lang#10814, which introduced these issues)
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.

2 participants