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

clippy bug report #8850

Closed
bobi6666 opened this issue May 20, 2022 · 12 comments · Fixed by #8896
Closed

clippy bug report #8850

bobi6666 opened this issue May 20, 2022 · 12 comments · Fixed by #8896
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@bobi6666
Copy link

bug.txt

@Alexendoo
Copy link
Member

Are you able to share the code this crashed on? If not running it with RUST_BACKTRACE=1 would still be helpful

@bobi6666
Copy link
Author

bobi6666 commented May 20, 2022 via email

@bobi6666
Copy link
Author

bobi6666 commented May 25, 2022 via email

@Alexendoo
Copy link
Member

If you're able to the full source code would be helpful so we can reproduce it ourselves, or if you could reduce the code to a smaller example that exhibits the error that would be even better

If you aren't able to share the full code, sharing the output of

set RUST_BACKTRACE=1
cargo clippy

Would also be helpful

@bobi6666
Copy link
Author

bobi6666 commented May 25, 2022 via email

@bobi6666
Copy link
Author

bobi6666 commented May 25, 2022 via email

@giraffate
Copy link
Contributor

Does this happen when executing cargo check or cargo build? Seeing backtraces, I couldn't find clippy logs.

@giraffate giraffate added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label May 26, 2022
@bobi6666
Copy link
Author

bobi6666 commented May 26, 2022 via email

@bobi6666
Copy link
Author

bobi6666 commented May 26, 2022 via email

@Alexendoo
Copy link
Member

Thanks for that!

Reduced:

fn f() -> usize { 1 }
static FN: fn() -> usize = f;

fn g() -> usize {
    let res = FN() + 1;
    res
}

Output:

error: internal compiler error: compiler/rustc_typeck/src/collect.rs:1931:13: unexpected sort of node in fn_sig(): Item(Item { ident: FN#0, def_id: DefId(0:4 ~ temp[70b1]::FN), kind: Static(Ty { hir_id: HirId { owner: DefId(0:4 ~ temp[70b1]::FN), local_id: 3 }, kind: BareFn(BareFnTy { unsafety: Normal, abi: Rust, generic_params: [], decl: FnDecl { inputs: [], output: Return(Ty { hir_id: HirId { owner: DefId(0:4 ~ temp[70b1]::FN), local_id: 1 }, kind: Path(Resolved(None, Path { span: src/lib.rs:2:20: 2:25 (#0), res: PrimTy(Uint(Usize)), segments: [PathSegment { ident: usize#0, hir_id: Some(HirId { owner: DefId(0:4 ~ temp[70b1]::FN), local_id: 2 }), res: Some(Err), args: None, infer_args: false }] })), span: src/lib.rs:2:20: 2:25 (#0) }), c_variadic: false, implicit_self: None }, param_names: [] }), span: src/lib.rs:2:12: 2:25 (#0) }, Not, BodyId { hir_id: HirId { owner: DefId(0:4 ~ temp[70b1]::FN), local_id: 5 } }), span: src/lib.rs:2:1: 2:30 (#0), vis_span: src/lib.rs:2:1: 2:1 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/compiler/rustc_errors/src/lib.rs:1335:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_typeck::collect::fn_sig
   8: <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::sty::Binder<rustc_middle::ty::sty::FnSig>>
   9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::FnSig>>>
  10: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::fn_sig, rustc_query_impl::plumbing::QueryCtxt>
  11: rustc_middle::ty::query::TyCtxtAt::fn_sig
             at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/compiler/rustc_middle/src/ty/query.rs:261:17
  12: rustc_middle::ty::query::<impl rustc_middle::ty::context::TyCtxt>::fn_sig
             at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/compiler/rustc_middle/src/ty/query.rs:242:17
  13: <clippy_lints::returns::BorrowVisitor as rustc_hir::intravisit::Visitor>::visit_expr
             at /home/alex/rust/clippy/clippy_lints/src/returns.rs:295:28
  14: rustc_hir::intravisit::walk_expr
             at /rustc/cd282d7f75da9080fda0f1740a729516e7fbec68/compiler/rustc_hir/src/intravisit.rs:1144:13
  15: clippy_lints::returns::last_statement_borrows
             at /home/alex/rust/clippy/clippy_lints/src/returns.rs:279:5
  16: <clippy_lints::returns::Return as rustc_lint::passes::LateLintPass>::check_block
             at /home/alex/rust/clippy/clippy_lints/src/returns.rs:92:17
  17: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_block
  18: rustc_hir::intravisit::walk_expr::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  19: rustc_hir::intravisit::walk_body::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  20: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_body
  21: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  22: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
  23: rustc_lint::late::late_lint_pass_crate::<rustc_lint::late::LateLintPassObjects>
  24: rustc_lint::late::late_lint_crate::<rustc_lint::BuiltinCombinedLateLintPass>
  25: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
  26: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
  27: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
  28: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}>
  29: rustc_interface::passes::analysis
  30: <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>>
  31: 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>>>
  32: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  33: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  34: <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>>
  35: 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}>
  36: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  37: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.63 (bc4d39e5f 2022-05-26)

query stack during panic:
#0 [fn_sig] computing function signature of `FN`
#1 [analysis] running analysis passes on this crate
end of query stack

@bobi6666
Copy link
Author

bobi6666 commented May 26, 2022 via email

@Alexendoo
Copy link
Member

Yeah, you can follow #8896 for details

@bors bors closed this as completed in 6553b98 May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants