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

src/tools/clippy/clippy_utils/src/consts.rs:286:18: impossible case reached #12389

Closed
matthiaskrgr opened this issue Feb 29, 2024 · 1 comment
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

Summary

const BYTE_PATTERN: &'static [u8; 5] = b"hello";

fn match_array(x: &Self::U) -> bool {
    match x {
        BYTE_PATTERN => true,
        _ => false
    }
}

fn main() {
    assert_eq!(match_array(-1.0, -2.0, -3.0, -4.0), true);
}

Version

rustc 1.78.0-nightly (384d26fc7 2024-02-29)
binary: rustc
commit-hash: 384d26fc7e3bdd7687cc17b2662b091f6017ec2a
commit-date: 2024-02-29
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

Backtrace

warning: constants have by default a `'static` lifetime
--> 7D862BF86F99BAAF200B97C10A73A3D222752900D776D5317472BA6930C216AA.rs:1:22
|
1 | const BYTE_PATTERN: &'static [u8; 5] = b"hello";
|                     -^^^^^^^-------- help: consider removing `'static`: `&[u8; 5]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
= note: `#[warn(clippy::redundant_static_lifetimes)]` on by default

warning: match expression looks like `matches!` macro
--> 7D862BF86F99BAAF200B97C10A73A3D222752900D776D5317472BA6930C216AA.rs:4:5
|
4 | /     match x {
5 | |         BYTE_PATTERN => true,
6 | |         _ => false
7 | |     }
| |_____^ help: try: `matches!(x, BYTE_PATTERN)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
= note: `#[warn(clippy::match_like_matches_macro)]` on by default

warning: used `assert_eq!` with a literal bool
--> 7D862BF86F99BAAF200B97C10A73A3D222752900D776D5317472BA6930C216AA.rs:11:5
 |
11 |     assert_eq!(match_array(-1.0, -2.0, -3.0, -4.0), true);
 |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 |
 = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
 = note: `#[warn(clippy::bool_assert_comparison)]` on by default
help: replace it with `assert!(..)`
 |
11 -     assert_eq!(match_array(-1.0, -2.0, -3.0, -4.0), true);
11 +     assert!(match_array(-1.0, -2.0, -3.0, -4.0));
 |

error: internal compiler error: src/tools/clippy/clippy_utils/src/consts.rs:286:18: impossible case reached

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
 0:     0x7fb9ced8cd36 - std::backtrace_rs::backtrace::libunwind::trace::h3a19003a2649a042
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
 1:     0x7fb9ced8cd36 - std::backtrace_rs::backtrace::trace_unsynchronized::hafb8387fdb677ced
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7fb9ced8cd36 - std::sys_common::backtrace::_print_fmt::h773b2eb83e893aac
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:68:5
 3:     0x7fb9ced8cd36 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9c4b0aaffae0e26
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7fb9cedddc8c - core::fmt::rt::Argument::fmt::hd27bd8720fbe360b
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/fmt/rt.rs:142:9
 5:     0x7fb9cedddc8c - core::fmt::write::h302aead198f704a5
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/fmt/mod.rs:1120:17
 6:     0x7fb9ced8159f - std::io::Write::write_fmt::h47ac46bdbb511a9b
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/io/mod.rs:1846:15
 7:     0x7fb9ced8cae4 - std::sys_common::backtrace::_print::hbe00a1350460cf41
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7fb9ced8cae4 - std::sys_common::backtrace::print::hfc2bd9d3d47d4566
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7fb9ced8f81b - std::panicking::default_hook::{{closure}}::hb9ff0341655a5c73
10:     0x7fb9ced8f577 - std::panicking::default_hook::hf368561d0cd93e13
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:292:9
11:     0x7fb9d1ca4a7c - std[fbb42328cecafc22]::panicking::update_hook::<alloc[c93a5f242b466a42]::boxed::Box<rustc_driver_impl[9cf1776aae3c094]::install_ice_hook::{closure#0}>>::{closure#0}
12:     0x7fb9ced8ff80 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2e1de234f5eaee61
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2030:9
13:     0x7fb9ced8ff80 - std::panicking::rust_panic_with_hook::he0aaa3480ffc94b9
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:783:13
14:     0x7fb9d1cd0ab4 - std[fbb42328cecafc22]::panicking::begin_panic::<rustc_errors[c41eb836d180d0d7]::ExplicitBug>::{closure#0}
15:     0x7fb9d1ccd9d6 - std[fbb42328cecafc22]::sys_common::backtrace::__rust_end_short_backtrace::<std[fbb42328cecafc22]::panicking::begin_panic<rustc_errors[c41eb836d180d0d7]::ExplicitBug>::{closure#0}, !>
16:     0x7fb9d1ccd6b6 - std[fbb42328cecafc22]::panicking::begin_panic::<rustc_errors[c41eb836d180d0d7]::ExplicitBug>
17:     0x7fb9d1cda611 - <rustc_errors[c41eb836d180d0d7]::diagnostic::BugAbort as rustc_errors[c41eb836d180d0d7]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18:     0x7fb9d20b2c3c - <rustc_errors[c41eb836d180d0d7]::DiagCtxt>::bug::<alloc[c93a5f242b466a42]::string::String>
19:     0x7fb9d2156f4b - rustc_middle[29894b38651fd55d]::util::bug::opt_span_bug_fmt::<rustc_span[e214f2a58174522b]::span_encoding::Span>::{closure#0}
20:     0x7fb9d213ae9a - rustc_middle[29894b38651fd55d]::ty::context::tls::with_opt::<rustc_middle[29894b38651fd55d]::util::bug::opt_span_bug_fmt<rustc_span[e214f2a58174522b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21:     0x7fb9d213ad38 - rustc_middle[29894b38651fd55d]::ty::context::tls::with_context_opt::<rustc_middle[29894b38651fd55d]::ty::context::tls::with_opt<rustc_middle[29894b38651fd55d]::util::bug::opt_span_bug_fmt<rustc_span[e214f2a58174522b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22:     0x7fb9d023f7f0 - rustc_middle[29894b38651fd55d]::util::bug::bug_fmt
23:     0x55fb74be73a1 - clippy_utils[f487de9bacdc7134]::consts::lit_to_mir_constant
24:     0x55fb74be8563 - <clippy_utils[f487de9bacdc7134]::consts::ConstEvalLateContext>::expr
25:     0x55fb74be8338 - <clippy_utils[f487de9bacdc7134]::consts::ConstEvalLateContext>::expr
26:     0x55fb74be7522 - clippy_utils[f487de9bacdc7134]::consts::constant_simple
27:     0x55fb74ab62b3 - <clippy_lints[b4b51f45f2daaf01]::operators::Operators as rustc_lint[959716dc0e2ee45]::passes::LateLintPass>::check_expr
28:     0x7fb9d2031cf2 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
29:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
30:     0x7fb9d2032390 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
31:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
32:     0x7fb9d2031e5f - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
33:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
34:     0x7fb9d2031e07 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
35:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
36:     0x7fb9d2031f32 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
37:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
38:     0x7fb9d203293c - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_block
39:     0x7fb9d2032194 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr::{closure#0}
40:     0x7fb9d2031b88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_expr
41:     0x7fb9d2031a88 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_nested_body
42:     0x7fb9d2032744 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_fn
43:     0x7fb9d2022054 - <rustc_lint[959716dc0e2ee45]::late::LateContextAndPass<rustc_lint[959716dc0e2ee45]::late::RuntimeCombinedLateLintPass> as rustc_hir[74fd38244b436780]::intravisit::Visitor>::visit_nested_item
44:     0x7fb9d3cb563d - rustc_lint[959716dc0e2ee45]::late::check_crate::{closure#0}
45:     0x7fb9d3cb5891 - rustc_lint[959716dc0e2ee45]::late::check_crate
46:     0x7fb9d3caf7a5 - rustc_interface[c8c0a49aa2897191]::passes::analysis
47:     0x7fb9d3cae499 - rustc_query_impl[1640d3938b91755e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1640d3938b91755e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 1usize]>>
48:     0x7fb9d3d326a5 - rustc_query_system[9c626cf6262cf6c2]::query::plumbing::try_execute_query::<rustc_query_impl[1640d3938b91755e]::DynamicConfig<rustc_query_system[9c626cf6262cf6c2]::query::caches::SingleCache<rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1640d3938b91755e]::plumbing::QueryCtxt, false>
49:     0x7fb9d3d32409 - rustc_query_impl[1640d3938b91755e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
50:     0x7fb9d3d39f3c - rustc_interface[c8c0a49aa2897191]::interface::run_compiler::<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}
51:     0x7fb9d3fde105 - std[fbb42328cecafc22]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_with_globals<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_pool_with_globals<rustc_interface[c8c0a49aa2897191]::interface::run_compiler<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>
52:     0x7fb9d3fddf32 - <<std[fbb42328cecafc22]::thread::Builder>::spawn_unchecked_<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_with_globals<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_pool_with_globals<rustc_interface[c8c0a49aa2897191]::interface::run_compiler<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#1} as core[3e98a99d3b4a7fa7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
53:     0x7fb9ced99955 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1310005556baa0fc
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2016:9
54:     0x7fb9ced99955 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h55d902c3660dd7c9
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2016:9
55:     0x7fb9ced99955 - std::sys::pal::unix::thread::Thread::new::thread_start::h5bd490f6a8b2e778
                             at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys/pal/unix/thread.rs:108:17
56:     0x7fb9cea9355a - <unknown>
57:     0x7fb9ceb10a3c - <unknown>
58:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please attach the file at `/tmp/im/rustc-ice-2024-02-29T18_29_18-1600183.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.78 (384d26f 2024-02-29)

error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
--> 7D862BF86F99BAAF200B97C10A73A3D222752900D776D5317472BA6930C216AA.rs:3:20
|
3 | fn match_array(x: &Self::U) -> bool {
|                    ^^^^ `Self` is only available in impls, traits, and type definitions

error: aborting due to 2 previous errors; 3 warnings emitted

For more information about this error, try `rustc --explain E0433`.

@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 Feb 29, 2024
@Jarcho
Copy link
Contributor

Jarcho commented Mar 24, 2024

Doesn't reproduce on latest nightly. E0433 is raised so lints shouldn't have even been running.

@Jarcho Jarcho closed this as completed Mar 24, 2024
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

No branches or pull requests

2 participants