Skip to content

ICE: pattern: attempt to add with overflow #136514

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn foo(-128..=127: u128) {}

original:

// Regression test for the ICE described in #82328. The pretty-printer for
// `-Zunpretty=hir,typed` would previously retrieve type-checking results
// when entering a body, which means that type information was not available
// for expressions occurring in function signatures, as in the `foo` example
//~^ ERROR the trait alias `SelfInput` is not dyn compatible [E0038]

//@ check-pass
//@ compile-flags: -Zunpretty=hir,typed
#![allow(dead_code)]

fn main() {}

fn foo(-128..=127: u128) {}

Version information

rustc 1.86.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.86.0-dev
LLVM version: 19.1.7

Possibly related line of code:

_ => {
return Ok(());
}
};
// Detect literal value out of range `[min, max]` inclusive, avoiding use of `-min` to
// prevent overflow/panic.
if (negated && lit_val > max + 1) || (!negated && lit_val > max) {
return Err(self.tcx.dcx().emit_err(LiteralOutOfRange { span, ty, min, max }));
}
Ok(())
}
fn lower_pattern_range(

Command:
/home/gh-matthiaskrgr/.rustup/toolchains/local-debug-assertions/bin/rustc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-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.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions