Closed
Description
Summary
A small derive macro crate at https://github.com/mayfieldiv/clippy-crash causes clippy to panic when run against the simple included test cargo clippy --tests
(it also reproduces against non-test code).
This reliably reproduces on stable Rust on Windows and macOS.
In the repo:
#[derive(Message)]
#[repr(u32)]
pub enum Foo {
Bar = 0, // clippy doesn't like this
// Bar = 0u32, // clippy's okay with this instead
}
The Message
derive macro generates this:
#[automatically_derived]
impl Foo {
fn compile_time_check_for_message_tag_collisions() {
#[repr(u32)]
enum FooSimple {
Bar = 0u32,
}
}
}
Clippy doesn't like something about the u32
not being in the enum's numeric literal
Version
rustc 1.62.1 (e092d0b6b 2022-07-16)
binary: rustc
commit-hash: e092d0b6b43f2de967af0887873151bb1c0b18d3
commit-date: 2022-07-16
host: aarch64-apple-darwin
release: 1.62.1
LLVM version: 14.0.5
Error output
Backtrace
thread 'rustc' panicked at 'byte index 18446744073709551614 is out of bounds of `0`', library/core/src/str/mod.rs:107:9
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::str::slice_error_fail_rt
3: core::ops::function::FnOnce::call_once
4: core::intrinsics::const_eval_select
5: core::str::slice_error_fail
6: <clippy_utils::numeric_literal::NumericLiteral>::from_lit_kind
7: <clippy_lints::literal_representation::LiteralDigitGrouping as rustc_lint::passes::EarlyLintPass>::check_expr
8: <rustc_lint::early::EarlyLintPassObjects as rustc_lint::passes::EarlyLintPass>::check_expr
9: <rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects> as rustc_ast::visit::Visitor>::visit_expr
10: rustc_ast::visit::walk_variant::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
11: rustc_ast::visit::walk_enum_def::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
12: rustc_ast::visit::walk_item::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
13: rustc_ast::visit::walk_stmt::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
14: rustc_ast::visit::walk_fn::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
15: rustc_ast::visit::walk_assoc_item::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
16: rustc_ast::visit::walk_item::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
17: rustc_ast::visit::walk_crate::<rustc_lint::early::EarlyContextAndPass<rustc_lint::early::EarlyLintPassObjects>>
18: rustc_lint::early::early_lint_node::<rustc_lint::early::EarlyLintPassObjects, &rustc_ast::ast::Crate>
19: rustc_lint::early::check_ast_node::<rustc_lint::BuiltinCombinedEarlyLintPass, &rustc_ast::ast::Crate>
20: <rustc_session::session::Session>::time::<(), rustc_interface::passes::configure_and_expand::{closure#8}>
21: <rustc_interface::passes::boxed_resolver::BoxedResolver>::access::<<rustc_interface::queries::Queries>::expansion::{closure#0}::{closure#0}, core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>>
22: <rustc_interface::queries::Queries>::expansion
23: <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>>
24: 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}>
25: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
26: <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>>