Skip to content

Commit 58df88f

Browse files
committed
Auto merge of #809 - RalfJung:intptrcast, r=<try>
use intptrcast for heap_allocator test; then it should work on Windows
2 parents 72b2e10 + 1f945cc commit 58df88f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

.appveyor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ install:
3131
build_script:
3232
- set RUST_TEST_NOCAPTURE=1
3333
- set RUST_BACKTRACE=1
34+
- set MIRI_BACKTRACE=1
3435
- set RUSTFLAGS=-C debug-assertions
3536
# Build and install miri
3637
- cargo build --release --all-features --all-targets

tests/run-pass/heap_allocator.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// compile-flag: -Zmiri-seed=
12
#![feature(allocator_api)]
23

34
use std::ptr::NonNull;
@@ -32,14 +33,15 @@ fn check_overalign_requests<T: Alloc>(mut allocator: T) {
3233
let size = 8;
3334
// Greater than `size`.
3435
let align = 16;
35-
// Miri is deterministic; no need to try many times.
36-
let iterations = 1;
36+
37+
let iterations = 5;
3738
unsafe {
3839
let pointers: Vec<_> = (0..iterations).map(|_| {
3940
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
4041
}).collect();
4142
for &ptr in &pointers {
42-
assert_eq!((ptr.as_ptr() as usize) % align, 0,
43+
let ptr = ptr.as_ptr() as usize;
44+
assert_eq!(ptr % align, 0,
4345
"Got a pointer less aligned than requested")
4446
}
4547

@@ -75,7 +77,6 @@ fn box_to_global() {
7577
fn main() {
7678
check_alloc(System);
7779
check_alloc(Global);
78-
#[cfg(not(target_os = "windows"))] // TODO: Inspects allocation base address on Windows; needs intptrcast model
7980
check_overalign_requests(System);
8081
check_overalign_requests(Global);
8182
global_to_box();

0 commit comments

Comments
 (0)