Skip to content

Commit 21e783d

Browse files
committed
Add run-pass tests for SpanlessEq/SpanlessHash ICE
1 parent f19eab9 commit 21e783d

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

tests/run-pass/ice-1782.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![allow(dead_code, unused_variables)]
2+
3+
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
4+
///
5+
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/1782
6+
7+
use std::{mem, ptr};
8+
9+
fn spanless_eq_ice() {
10+
let txt = "something";
11+
match txt {
12+
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
13+
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
14+
}
15+
}
16+
17+
fn main() {}

tests/run-pass/ice-2499.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(dead_code)]
2+
3+
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
4+
///
5+
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2499
6+
7+
fn f(s: &[u8]) -> bool {
8+
let t = s[0] as char;
9+
10+
match t {
11+
'E' | 'W' => {}
12+
'T' => if &s[0..(0 + 4)] != &['0' as u8; 4] {
13+
return false;
14+
} else {
15+
return true;
16+
},
17+
_ => {
18+
return false;
19+
}
20+
}
21+
true
22+
}
23+
24+
fn main() {}

tests/run-pass/ice-2594.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![allow(dead_code, unused_variables)]
2+
3+
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
4+
///
5+
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2594
6+
7+
fn spanless_hash_ice() {
8+
let txt = "something";
9+
let empty_header: [u8; 1] = [1; 1];
10+
11+
match txt {
12+
"something" => {
13+
let mut headers = [empty_header; 1];
14+
}
15+
"" => (),
16+
_ => (),
17+
}
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)