Skip to content

Commit 381c733

Browse files
committed
Merge remote-tracking branch 'origin/master' into fat-ptr-eq
2 parents e04e868 + b468789 commit 381c733

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2019-02-13
1+
nightly-2019-02-14

tests/run-pass/heap_system.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//ignore-windows: Inspects allocation base address on Windows
2+
#![feature(allocator_api)]
3+
4+
use std::alloc::{Global, Alloc, Layout, System};
5+
6+
fn check_overalign_requests<T: Alloc>(mut allocator: T) {
7+
let size = 8;
8+
let align = 16; // greater than size
9+
let iterations = 1; // Miri is deterministic, no need to try many times
10+
unsafe {
11+
let pointers: Vec<_> = (0..iterations).map(|_| {
12+
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
13+
}).collect();
14+
for &ptr in &pointers {
15+
assert_eq!((ptr.as_ptr() as usize) % align, 0,
16+
"Got a pointer less aligned than requested")
17+
}
18+
19+
// Clean up
20+
for &ptr in &pointers {
21+
allocator.dealloc(ptr, Layout::from_size_align(size, align).unwrap())
22+
}
23+
}
24+
}
25+
26+
fn main() {
27+
check_overalign_requests(System);
28+
check_overalign_requests(Global);
29+
}

tests/run-pass/strings.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ fn fat_pointer_on_32_bit() {
1818
Some(5).expect("foo");
1919
}
2020

21+
fn str_indexing() {
22+
let mut x = "Hello".to_string();
23+
let _v = &mut x[..3]; // Test IndexMut on String.
24+
}
25+
2126
fn main() {
2227
assert_eq!(empty(), "");
2328
assert_eq!(hello(), "Hello, world!");
2429
assert_eq!(hello_bytes(), b"Hello, world!");
2530
assert_eq!(hello_bytes_fat(), b"Hello, world!");
31+
2632
fat_pointer_on_32_bit(); // Should run without crashing.
33+
str_indexing();
2734
}

0 commit comments

Comments
 (0)