Fix overflow detection in MIR evaluation

With a bit of higher-order macros everything sorts out well.

And also fix a discovered bug when comparing long strings.
This commit is contained in:
Chayim Refael Friedman 2025-01-02 11:49:21 +02:00
parent 4500856e45
commit bb400ca121
3 changed files with 206 additions and 19 deletions

View file

@ -879,3 +879,32 @@ fn main() {
"#,
);
}
#[test]
fn long_str_eq_same_prefix() {
check_pass_and_stdio(
r#"
//- minicore: slice, index, coerce_unsized
type pthread_key_t = u32;
type c_void = u8;
type c_int = i32;
extern "C" {
pub fn write(fd: i32, buf: *const u8, count: usize) -> usize;
}
fn main() {
// More than 16 bytes, the size of `i128`.
let long_str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
let output = match long_str {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" => b"true" as &[u8],
_ => b"false",
};
write(1, &output[0], output.len());
}
"#,
"false",
"",
);
}