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

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

Closed
matthiaskrgr opened this issue Feb 7, 2025 · 3 comments · Fixed by #136760
Closed

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

matthiaskrgr opened this issue Feb 7, 2025 · 3 comments · Fixed by #136760
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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


@matthiaskrgr matthiaskrgr added 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. labels Feb 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 7, 2025
@matthiaskrgr
Copy link
Member Author

#136393 cc @oli-obk

@matthiaskrgr
Copy link
Member Author

smaller

fn main() {
    match (9, 0i8) {
        (1.., -34665) | (..) => {}
    }
}

@theemathas
Copy link
Contributor

smaller

fn main() {
    if let -129 = 0i8 {}
}

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue S-has-bisection Status: a bisection has been found for this issue A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 7, 2025
@chenyukang chenyukang self-assigned this Feb 9, 2025
Urgau added a commit to Urgau/rust that referenced this issue Feb 9, 2025
…t-crash, r=oli-obk

Fix unwrap error in overflowing int literal

Fixes rust-lang#136675

it's maybe `negative` only from [check_lit](https://github.com/chenyukang/rust/blob/526e3288feb68eac55013746e03fb54d6a0b9a1e/compiler/rustc_lint/src/types.rs#L546), in this scenario the fields in `TypeLimits` is none.

r? `@oli-obk`
@bors bors closed this as completed in b5b460d Feb 10, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 10, 2025
Rollup merge of rust-lang#136760 - chenyukang:fix-overflowing-int-lint-crash, r=oli-obk

Fix unwrap error in overflowing int literal

Fixes rust-lang#136675

it's maybe `negative` only from [check_lit](https://github.com/chenyukang/rust/blob/526e3288feb68eac55013746e03fb54d6a0b9a1e/compiler/rustc_lint/src/types.rs#L546), in this scenario the fields in `TypeLimits` is none.

r? ``@oli-obk``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants