Add run-pass tests for SpanlessEq/SpanlessHash ICE

This commit is contained in:
Philipp Hansch 2018-05-12 13:41:03 +02:00
parent f19eab94fb
commit 21e783d3b6
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
3 changed files with 61 additions and 0 deletions

View 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() {}

View 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() {}

View 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() {}