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 crashes: couldn't extract literal #96721

Closed
matthiaskrgr opened this issue May 5, 2022 · 2 comments
Closed

clippy crashes: couldn't extract literal #96721

matthiaskrgr opened this issue May 5, 2022 · 2 comments
Labels
A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

clippy-driver crash.rs

macro_rules! foo {
    () => {"bar.rs"};
}

#[path = foo!()] //~ ERROR malformed `path` attribute
mod abc;

fn main() {}

CC @nnethercote you added this assert here: https://github.com/rust-lang/rust/pull/96546/files#diff-00567f9be31678eec46651e6157f0eaaa47d1f344eb61b8a63f87edfa7bf6b14R1589

looks like this triggers an ICE in clippy :(

Meta

clippy-driver --version:

clippy 0.1.62 (4c60a0e 2022-05-04) / 

rustc 1.62.0-nightly (4c60a0ea5 2022-05-04)
binary: rustc
commit-hash: 4c60a0ea5b2385d7400df9db1ad04e96f2a4c154
commit-date: 2022-05-04
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1
Backtrace

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: ./src/test/ui/modules/path-macro.rs:5:10: 5:13 (#0), segments: [PathSegment { ident: foo#0, id: NodeId(4294967040), args: None }], tokens: None }, args: Delimited(DelimSpan { open: ./src/test/ui/modules/path-macro.rs:5:14: 5:15 (#0), close: ./src/test/ui/modules/path-macro.rs:5:15: 5:16 (#0) }, Parenthesis, TokenStream([])), prior_type_ascription: None }), span: ./src/test/ui/modules/path-macro.rs:5:10: 5:16 (#0), attrs: ThinVec(None), tokens: Some(LazyTokenStream(AttrAnnotatedTokenStream([(Token(Token { kind: Ident("foo", false), span: ./src/test/ui/modules/path-macro.rs:5:10: 5:13 (#0) }), Joint), (Token(Token { kind: Not, span: ./src/test/ui/modules/path-macro.rs:5:13: 5:14 (#0) }), Alone), (Delimited(DelimSpan { open: ./src/test/ui/modules/path-macro.rs:5:14: 5:15 (#0), close: ./src/test/ui/modules/path-macro.rs:5:15: 5:16 (#0) }, Parenthesis, AttrAnnotatedTokenStream([])), Alone)]))) }', compiler/rustc_ast/src/ast.rs:1595:21
stack backtrace:
   0:     0x7f66c929df7d - std::backtrace_rs::backtrace::libunwind::trace::h60df59602e900a84
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f66c929df7d - std::backtrace_rs::backtrace::trace_unsynchronized::h4de728a76dc3c11c
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f66c929df7d - std::sys_common::backtrace::_print_fmt::h3ea622c4324f07d6
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f66c929df7d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he809f9fc56245962
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f66c92f9cbc - core::fmt::write::hd10d9412db84b2f0
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f66c928f671 - std::io::Write::write_fmt::h6d2b0777a373199e
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/io/mod.rs:1655:15
   6:     0x7f66c92a0c95 - std::sys_common::backtrace::_print::hf9320b3c85b5c9c3
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f66c92a0c95 - std::sys_common::backtrace::print::hd5e6a4965c8f48d7
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f66c92a0c95 - std::panicking::default_hook::{{closure}}::h9bcde255b6f94a95
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:295:22
   9:     0x7f66c92a0909 - std::panicking::default_hook::h1184cc1001dcee07
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:314:9
  10:     0x562653d270fd - clippy_driver[1eccbcd622942942]::ICE_HOOK::{closure#0}::{closure#0}
  11:     0x7f66c92a1466 - std::panicking::rust_panic_with_hook::hd0b795e06b63fc0c
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:702:17
  12:     0x7f66c92a1267 - std::panicking::begin_panic_handler::{{closure}}::h458061200738767c
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:588:13
  13:     0x7f66c929e434 - std::sys_common::backtrace::__rust_end_short_backtrace::hd840801340c49037
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f66c92a0f99 - rust_begin_unwind
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/panicking.rs:584:5
  15:     0x7f66c9266263 - core::panicking::panic_fmt::h07e87b1463fff16d
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/core/src/panicking.rs:142:14
  16:     0x7f66cbb03d89 - <rustc_ast[8fa7177330379e9f]::ast::MacArgs>::inner_tokens
  17:     0x562653f8bf20 - <clippy_lints[5d4f84193d39f3f8]::attrs::EarlyAttributes as rustc_lint[430ed1419a3d540e]::passes::EarlyLintPass>::check_item
  18:     0x7f66ca8e3141 - <rustc_lint[430ed1419a3d540e]::early::EarlyLintPassObjects as rustc_lint[430ed1419a3d540e]::passes::EarlyLintPass>::check_item
  19:     0x7f66c9bbb174 - <rustc_lint[430ed1419a3d540e]::early::EarlyContextAndPass<rustc_lint[430ed1419a3d540e]::early::EarlyLintPassObjects> as rustc_ast[8fa7177330379e9f]::visit::Visitor>::visit_item
  20:     0x7f66c9b7ed20 - rustc_ast[8fa7177330379e9f]::visit::walk_crate::<rustc_lint[430ed1419a3d540e]::early::EarlyContextAndPass<rustc_lint[430ed1419a3d540e]::early::EarlyLintPassObjects>>
  21:     0x7f66c9b57ba9 - <&rustc_ast[8fa7177330379e9f]::ast::Crate as rustc_lint[430ed1419a3d540e]::early::EarlyCheckNode>::check::<rustc_lint[430ed1419a3d540e]::early::EarlyLintPassObjects>
  22:     0x7f66c9bba815 - rustc_lint[430ed1419a3d540e]::early::early_lint_node::<rustc_lint[430ed1419a3d540e]::early::EarlyLintPassObjects, &rustc_ast[8fa7177330379e9f]::ast::Crate>
  23:     0x7f66cbb92c1a - rustc_lint[430ed1419a3d540e]::early::check_ast_node::<rustc_lint[430ed1419a3d540e]::BuiltinCombinedPreExpansionLintPass, &rustc_ast[8fa7177330379e9f]::ast::Crate>
  24:     0x7f66cbb6672f - rustc_interface[d19b96c655da2cbf]::passes::configure_and_expand
  25:     0x7f66cbb8c877 - <rustc_interface[d19b96c655da2cbf]::queries::Queries>::expansion
  26:     0x7f66cbb35c49 - <rustc_interface[d19b96c655da2cbf]::interface::Compiler>::enter::<rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}::{closure#2}, core[d929402d3f6fe1ad]::result::Result<core[d929402d3f6fe1ad]::option::Option<rustc_interface[d19b96c655da2cbf]::queries::Linker>, rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>
  27:     0x7f66cbb5f16f - rustc_span[46e75677c1ee720]::with_source_map::<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_interface[d19b96c655da2cbf]::interface::create_compiler_and_run<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}>::{closure#1}>
  28:     0x7f66cbb36994 - rustc_interface[d19b96c655da2cbf]::interface::create_compiler_and_run::<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}>
  29:     0x7f66cbb34632 - <scoped_tls[e18f92e1d327fbf1]::ScopedKey<rustc_span[46e75677c1ee720]::SessionGlobals>>::set::<rustc_interface[d19b96c655da2cbf]::interface::run_compiler<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}>::{closure#0}, core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>
  30:     0x7f66cbb4c72f - std[fa812e4e74340a6e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d19b96c655da2cbf]::util::run_in_thread_pool_with_globals<rustc_interface[d19b96c655da2cbf]::interface::run_compiler<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}>::{closure#0}, core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>::{closure#0}, core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>
  31:     0x7f66cbb4c869 - <<std[fa812e4e74340a6e]::thread::Builder>::spawn_unchecked_<rustc_interface[d19b96c655da2cbf]::util::run_in_thread_pool_with_globals<rustc_interface[d19b96c655da2cbf]::interface::run_compiler<core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>, rustc_driver[eac439b5877b29b]::run_compiler::{closure#1}>::{closure#0}, core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>::{closure#0}, core[d929402d3f6fe1ad]::result::Result<(), rustc_errors[a7c2dcfd55d4989c]::ErrorGuaranteed>>::{closure#1} as core[d929402d3f6fe1ad]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f66c92ab3b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb67e12bf0289e79c
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/alloc/src/boxed.rs:1866:9
  33:     0x7f66c92ab3b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h579da739f09a917c
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/alloc/src/boxed.rs:1866:9
  34:     0x7f66c92ab3b3 - std::sys::unix::thread::Thread::new::thread_start::h7b7b375f63dbd91d
                               at /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f66c8f9b5c2 - start_thread
  36:     0x7f66c9020584 - __clone
  37:                0x0 - <unknown>

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

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-clippy Area: Clippy labels May 5, 2022
@nnethercote
Copy link
Contributor

A workaround to avoid this was added here: rust-lang/rust-clippy@0062829. I've added a comment on that commit suggesting a slightly cleaner fix.

@matthiaskrgr
Copy link
Member Author

Fixed via rust-lang/rust-clippy@0062829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants