mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Auto merge of #7473 - Jarcho:ice_7340, r=Manishearth
Fix ICE in `is_integer_const` fixes: #7340 changelog: Fix ICE in `modulo_one` in const contexts
This commit is contained in:
commit
e93df0bef9
2 changed files with 8 additions and 6 deletions
|
@ -909,12 +909,8 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool
|
||||||
if is_integer_literal(e, value) {
|
if is_integer_literal(e, value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let map = cx.tcx.hir();
|
let enclosing_body = cx.tcx.hir().local_def_id(cx.tcx.hir().enclosing_body_owner(e.hir_id));
|
||||||
let parent_item = map.get_parent_item(e.hir_id);
|
if let Some((Constant::Int(v), _)) = constant(cx, cx.tcx.typeck(enclosing_body), e) {
|
||||||
if let Some((Constant::Int(v), _)) = map
|
|
||||||
.maybe_body_owned_by(parent_item)
|
|
||||||
.and_then(|body_id| constant(cx, cx.tcx.typeck_body(body_id), e))
|
|
||||||
{
|
|
||||||
value == v
|
value == v
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
6
tests/ui/crashes/ice-7340.rs
Normal file
6
tests/ui/crashes/ice-7340.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#![allow(clippy::no_effect)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
const CONSTANT: usize = 8;
|
||||||
|
[1; 1 % CONSTANT];
|
||||||
|
}
|
Loading…
Reference in a new issue