rust/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
631 B
Rust
Raw Normal View History

#![allow(dead_code)]
2018-07-20 02:41:09 +00:00
const C: *const u8 = &0;
// Make sure we also find pointers nested in other types.
const C_INNER: (*const u8, u8) = (C, 0);
2018-07-20 02:41:09 +00:00
fn foo(x: *const u8) {
match x {
C => {} //~ERROR: behave unpredictably
2018-07-20 02:41:09 +00:00
_ => {}
}
}
fn foo2(x: *const u8) {
match (x, 1) {
C_INNER => {} //~ERROR: behave unpredictably
_ => {}
}
}
2018-07-20 02:41:09 +00:00
const D: *const [u8; 4] = b"abcd";
const STR: *const str = "abcd";
2018-07-20 02:41:09 +00:00
fn main() {
match D {
D => {} //~ERROR: behave unpredictably
2018-07-20 02:41:09 +00:00
_ => {}
}
match STR {
STR => {} //~ERROR: behave unpredictably
_ => {}
}
2018-07-20 02:41:09 +00:00
}