Skip to content

ICE: None in type limit lint(?) #136675

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    match (99, 0i8) {
        FOO_REF_REF => {}

        (1.., ..=-34665) | (..=-1, 1..) => {}
    }
}

original:

//@ check-pass
fn main() {
    match (99, 0i8) {
        FOO_REF_REF => {}
        (..=-1, ..=0) => {}
        (1.., 0..) => {}
        (1.., ..=-34665) | (..=-1, 1..) => {}
    }
}

Version information

rustc 1.86.0-nightly (f37c19062 2025-02-07)
binary: rustc
commit-hash: f37c19062c7e7dceff77eca8f70fb222e4d36590
commit-date: 2025-02-07
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

if lint_overflowing_range_endpoint(cx, lit, v, max, hir_id, span, t.name_str()) {
// The overflowing literal lint was emitted by `lint_overflowing_range_endpoint`.
return;
}
let span = if negative { type_limits.negated_expr_span.unwrap() } else { span };
let lit = cx
.sess()
.source_map()
.span_to_snippet(span)
.unwrap_or_else(|_| if negative { format!("-{v}") } else { v.to_string() });
let help = get_type_suggestion(cx.typeck_results().node_type(hir_id), v, negative)

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: unreachable pattern
 --> /tmp/icemaker_global_tempdir.AW0aLuAWdDkv/rustc_testrunner_tmpdir_reporting.HQp0kdKKXbRi/mvce.rs:5:9
  |
3 |         FOO_REF_REF => {}
  |         ----------- matches any value
4 |
5 |         (1.., ..=-34665) | (..=-1, 1..) => {}
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no value can reach this
  |
  = note: `#[warn(unreachable_patterns)]` on by default

warning: unused variable: `FOO_REF_REF`
 --> /tmp/icemaker_global_tempdir.AW0aLuAWdDkv/rustc_testrunner_tmpdir_reporting.HQp0kdKKXbRi/mvce.rs:3:9
  |
3 |         FOO_REF_REF => {}
  |         ^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_FOO_REF_REF`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable `FOO_REF_REF` should have a snake case name
 --> /tmp/icemaker_global_tempdir.AW0aLuAWdDkv/rustc_testrunner_tmpdir_reporting.HQp0kdKKXbRi/mvce.rs:3:9
  |
3 |         FOO_REF_REF => {}
  |         ^^^^^^^^^^^ help: convert the identifier to snake case: `foo_ref_ref`
  |
  = note: `#[warn(non_snake_case)]` on by default


thread 'rustc' panicked at compiler/rustc_lint/src/types/literal.rs:277:64:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7e6c3f839d60 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hef1a0256acb3f96c
   1:     0x7e6c40014726 - core::fmt::write::h687d7593d7725de0
   2:     0x7e6c41365c91 - std::io::Write::write_fmt::he6f9ddf5268f18e3
   3:     0x7e6c3f839bc2 - std::sys::backtrace::BacktraceLock::print::hf016bb5be23977e6
   4:     0x7e6c3f83c042 - std::panicking::default_hook::{{closure}}::hc053379abb03fec5
   5:     0x7e6c3f83beca - std::panicking::default_hook::h9b121feeded61e43
   6:     0x7e6c3e997229 - std[a6cce1d5770a9a78]::panicking::update_hook::<alloc[d6dea5eea5be178c]::boxed::Box<rustc_driver_impl[708616ef23164f65]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7e6c3f83cb83 - std::panicking::rust_panic_with_hook::h97c416e18b1910e9
   8:     0x7e6c3f83c846 - std::panicking::begin_panic_handler::{{closure}}::h6d54c6ceafafbb98
   9:     0x7e6c3f83a249 - std::sys::backtrace::__rust_end_short_backtrace::hd0fb2594cc8f147d
  10:     0x7e6c3f83c53d - rust_begin_unwind
  11:     0x7e6c3c44a6c0 - core::panicking::panic_fmt::h88f7b3b9f607e06b
  12:     0x7e6c3d0180bc - core::panicking::panic::hea7da4de2a9e5999
  13:     0x7e6c3d49b039 - core::option::unwrap_failed::hd9241e5695611b49
  14:     0x7e6c40350d5b - <rustc_lint[ed9a2eae3d2bd783]::types::TypeLimits as rustc_lint[ed9a2eae3d2bd783]::passes::LateLintPass>::check_lit
  15:     0x7e6c4034ba03 - rustc_hir[4e1e725cfe17f609]::intravisit::walk_pat::<rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass>>
  16:     0x7e6c4034b96a - rustc_hir[4e1e725cfe17f609]::intravisit::walk_pat::<rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass>>
  17:     0x7e6c4035148c - <rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass> as rustc_hir[4e1e725cfe17f609]::intravisit::Visitor>::visit_expr
  18:     0x7e6c4034e118 - rustc_hir[4e1e725cfe17f609]::intravisit::walk_block::<rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass>>
  19:     0x7e6c4034f1d6 - <rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass> as rustc_hir[4e1e725cfe17f609]::intravisit::Visitor>::visit_expr::{closure#0}
  20:     0x7e6c4034f11f - <rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass> as rustc_hir[4e1e725cfe17f609]::intravisit::Visitor>::visit_nested_body
  21:     0x7e6c403410ac - <rustc_lint[ed9a2eae3d2bd783]::late::LateContextAndPass<rustc_lint[ed9a2eae3d2bd783]::BuiltinCombinedModuleLateLintPass> as rustc_hir[4e1e725cfe17f609]::intravisit::Visitor>::visit_nested_item
  22:     0x7e6c4033f8ab - rustc_lint[ed9a2eae3d2bd783]::lint_mod
  23:     0x7e6c4033f61f - rustc_query_impl[3d940321e84da6d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3d940321e84da6d5]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[41e81d935edc4384]::query::erase::Erased<[u8; 0usize]>>
  24:     0x7e6c40adf141 - rustc_query_system[de64e94cc3e4065c]::query::plumbing::try_execute_query::<rustc_query_impl[3d940321e84da6d5]::DynamicConfig<rustc_query_system[de64e94cc3e4065c]::query::caches::DefaultCache<rustc_span[2dce28d318afa168]::def_id::LocalModDefId, rustc_middle[41e81d935edc4384]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3d940321e84da6d5]::plumbing::QueryCtxt, false>
  25:     0x7e6c40add318 - rustc_query_impl[3d940321e84da6d5]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7e6c40adcf02 - rustc_lint[ed9a2eae3d2bd783]::late::check_crate::{closure#1}
  27:     0x7e6c40adca78 - rustc_lint[ed9a2eae3d2bd783]::late::check_crate
  28:     0x7e6c40ae0264 - rustc_interface[acdb31c8c95b7f85]::passes::analysis
  29:     0x7e6c40ae002f - rustc_query_impl[3d940321e84da6d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3d940321e84da6d5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[41e81d935edc4384]::query::erase::Erased<[u8; 0usize]>>
  30:     0x7e6c40fd4ad5 - rustc_query_system[de64e94cc3e4065c]::query::plumbing::try_execute_query::<rustc_query_impl[3d940321e84da6d5]::DynamicConfig<rustc_query_system[de64e94cc3e4065c]::query::caches::SingleCache<rustc_middle[41e81d935edc4384]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3d940321e84da6d5]::plumbing::QueryCtxt, false>
  31:     0x7e6c40fd480e - rustc_query_impl[3d940321e84da6d5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7e6c40f5082b - rustc_interface[acdb31c8c95b7f85]::passes::create_and_enter_global_ctxt::<core[58be5d4f777b0c3d]::option::Option<rustc_interface[acdb31c8c95b7f85]::queries::Linker>, rustc_driver_impl[708616ef23164f65]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  33:     0x7e6c40fb861c - rustc_interface[acdb31c8c95b7f85]::interface::run_compiler::<(), rustc_driver_impl[708616ef23164f65]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7e6c40eb2544 - std[a6cce1d5770a9a78]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[acdb31c8c95b7f85]::util::run_in_thread_with_globals<rustc_interface[acdb31c8c95b7f85]::util::run_in_thread_pool_with_globals<rustc_interface[acdb31c8c95b7f85]::interface::run_compiler<(), rustc_driver_impl[708616ef23164f65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7e6c40eb2219 - <<std[a6cce1d5770a9a78]::thread::Builder>::spawn_unchecked_<rustc_interface[acdb31c8c95b7f85]::util::run_in_thread_with_globals<rustc_interface[acdb31c8c95b7f85]::util::run_in_thread_pool_with_globals<rustc_interface[acdb31c8c95b7f85]::interface::run_compiler<(), rustc_driver_impl[708616ef23164f65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[58be5d4f777b0c3d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7e6c40eb19ab - std::sys::pal::unix::thread::Thread::new::thread_start::he51ec36ef00e0c20
  37:     0x7e6c3b05f39d - <unknown>
  38:     0x7e6c3b0e449c - <unknown>
  39:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.86.0-nightly (f37c19062 2025-02-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
warning: 3 warnings emitted


Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 7, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 7, 2025
  3. matthiaskrgr commented on Feb 7, 2025

    @matthiaskrgr
    MemberAuthor
  4. matthiaskrgr commented on Feb 7, 2025

    @matthiaskrgr
    MemberAuthor

    smaller

    fn main() {
        match (9, 0i8) {
            (1.., -34665) | (..) => {}
        }
    }
  5. theemathas commented on Feb 7, 2025

    @theemathas
    Contributor

    smaller

    fn main() {
        if let -129 = 0i8 {}
    }
  6. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    S-has-bisectionStatus: A bisection has been found for this issue
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 7, 2025
  7. self-assigned this
    on Feb 9, 2025
  8. added a commit that references this issue on Feb 9, 2025
    2d5a1bd
  9. added a commit that references this issue on Feb 9, 2025
    b5b460d
  10. added a commit that references this issue on Feb 10, 2025
    7e9a07e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions