mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 18:26:19 +00:00
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:
parent
4500856e45
commit
bb400ca121
3 changed files with 206 additions and 19 deletions
|
|
@ -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",
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue