Add run-pass tests for SpanlessEq/SpanlessHash ICE
This commit is contained in:
parent
f19eab94fb
commit
21e783d3b6
3 changed files with 61 additions and 0 deletions
17
tests/run-pass/ice-1782.rs
Normal file
17
tests/run-pass/ice-1782.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
|
||||
///
|
||||
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/1782
|
||||
|
||||
use std::{mem, ptr};
|
||||
|
||||
fn spanless_eq_ice() {
|
||||
let txt = "something";
|
||||
match txt {
|
||||
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
|
||||
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
24
tests/run-pass/ice-2499.rs
Normal file
24
tests/run-pass/ice-2499.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
||||
///
|
||||
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2499
|
||||
|
||||
fn f(s: &[u8]) -> bool {
|
||||
let t = s[0] as char;
|
||||
|
||||
match t {
|
||||
'E' | 'W' => {}
|
||||
'T' => if &s[0..(0 + 4)] != &['0' as u8; 4] {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
},
|
||||
_ => {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn main() {}
|
20
tests/run-pass/ice-2594.rs
Normal file
20
tests/run-pass/ice-2594.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
||||
///
|
||||
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2594
|
||||
|
||||
fn spanless_hash_ice() {
|
||||
let txt = "something";
|
||||
let empty_header: [u8; 1] = [1; 1];
|
||||
|
||||
match txt {
|
||||
"something" => {
|
||||
let mut headers = [empty_header; 1];
|
||||
}
|
||||
"" => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in a new issue