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

Unexpected Panic: couldn't extract literal #8791

Closed wcampbell0x2a closed 2 years ago

wcampbell0x2a commented 2 years ago

I run clippy nightly and saw a panic in my CI.

Here is the link to the CI job: https://github.com/rsadsb/adsb_deku/runs/6314734506?check_suite_focus=true

thread 'rustc' panicked at 'internal error: entered unreachable code: couldn't extract literal when getting inner tokens: Expr { id: NodeId(4294967040), kind: MacCall(MacCall { path: Path { span: libadsb_deku/src/lib.rs:151:9: 151:20 (#0), segments: [PathSegment { ident: include_str#0, id: NodeId(4294967040), args: None }], tokens: None }, args: Delimited(DelimSpan { open: libadsb_deku/src/lib.rs:151:21: 151:22 (#0), close: libadsb_deku/src/lib.rs:151:36: 151:37 (#0) }, Parenthesis, TokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "../README.md", suffix: None }), span: libadsb_deku/src/lib.rs:151:22: 151:36 (#0) }), Alone)])), prior_type_ascription: None }), span: libadsb_deku/src/lib.rs:151:9: 151:37 (#0), attrs: ThinVec(None), tokens: Some(LazyTokenStream(AttrAnnotatedTokenStream([(Token(Token { kind: Ident("include_str", false), span: libadsb_deku/src/lib.rs:151:9: 151:20 (#0) }), Joint), (Token(Token { kind: Not, span: libadsb_deku/src/lib.rs:151:20: 151:21 (#0) }), Alone), (Delimited(DelimSpan { open: libadsb_deku/src/lib.rs:151:21: 151:22 (#0), close: libadsb_deku/src/lib.rs:151:36: 151:37 (#0) }, Parenthesis, AttrAnnotatedTokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "../README.md", suffix: None }), span: libadsb_deku/src/lib.rs:151:22: 151:36 (#0) }), Alone)])), Alone)]))) }', compiler/rustc_ast/src/ast.rs:1595:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic
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.62 (4c60a0e 2022-05-04)

query stack during panic:
end of query stack
error: could not compile `adsb_deku`
Serial-ATA commented 2 years ago

Looks like https://github.com/rust-lang/rust/issues/96721

wcampbell0x2a commented 2 years ago

I ran with RUST_BACKTRACE:

❯ RUST_BACKTRACE=1 cargo clippy -- -W clippy::pedantic -W clippy::nursery
    Checking adsb_deku v0.5.1 (project_path)
thread 'rustc' panicked at 'internal error: entered unreachable code: couldn't extract literal when getting inner tokens: Expr { id: NodeId(4294967040), kind: MacCall(MacCall { path: Path { span: libadsb_deku/src/lib.rs:151:9: 151:20 (#0), segments: [PathSegment { ident: include_str#0, id: NodeId(4294967040), args: None }], tokens: None }, args: Delimited(DelimSpan { open: libadsb_deku/src/lib.rs:151:21: 151:22 (#0), close: libadsb_deku/src/lib.rs:151:36: 151:37 (#0) }, Parenthesis, TokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "../README.md", suffix: None }), span: libadsb_deku/src/lib.rs:151:22: 151:36 (#0) }), Alone)])), prior_type_ascription: None }), span: libadsb_deku/src/lib.rs:151:9: 151:37 (#0), attrs: ThinVec(None), tokens: Some(LazyTokenStream(AttrAnnotatedTokenStream([(Token(Token { kind: Ident("include_str", false), span: libadsb_deku/src/lib.rs:151:9: 151:20 (#0) }), Joint), (Token(Token { kind: Not, span: libadsb_deku/src/lib.rs:151:20: 151:21 (#0) }), Alone), (Delimited(DelimSpan { open: libadsb_deku/src/lib.rs:151:21: 151:22 (#0), close: libadsb_deku/src/lib.rs:151:36: 151:37 (#0) }, Parenthesis, AttrAnnotatedTokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "../README.md", suffix: None }), span: libadsb_deku/src/lib.rs:151:22: 151:36 (#0) }), Alone)])), Alone)]))) }', compiler/rustc_ast/src/ast.rs:1595:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/core/src/panicking.rs:142:14
   2: <rustc_ast::ast::MacArgs>::inner_tokens
   3: <clippy_lints::attrs::EarlyAttributes as rustc_lint::passes::EarlyLintPass>::check_item
   4: <rustc_lint::early::EarlyLintPassObjects as rustc_lint::passes::EarlyLintPass>::check_item
   5: <rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects> as rustc_ast::visit::Visitor>::visit_item
   6: rustc_ast::visit::walk_crate::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
   7: <&rustc_ast::ast::Crate as rustc_lint::early::EarlyCheckNode>::check::<rustc_lint::early::EarlyLintPassObjects>
   8: rustc_lint::early::early_lint_node::<rustc_lint::early::EarlyLintPassObjects, &rustc_ast::ast::Crate>
   9: rustc_lint::early::check_ast_node::<rustc_lint::BuiltinCombinedPreExpansionLintPass, &rustc_ast::ast::Crate>
  10: rustc_interface::passes::configure_and_expand
  11: <rustc_interface::queries::Queries>::expansion
  12: <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>>
  13: 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}>
  14: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  15: <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.

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.62 (4c60a0e 2022-05-04)

query stack during panic:
end of query stack
error: could not compile `adsb_deku`
Jarcho commented 2 years ago

This has been fixed as of #8788