Skip to content

Commit 28969f4

Browse files
authored
Merge pull request rust-lang#238 from RalfJung/tests
Add little script to build libstd
2 parents ea2b192 + 3e7f69a commit 28969f4

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ before_script:
1212
script:
1313
- |
1414
# get ourselves a MIR-ful libstd
15-
cd xargo &&
16-
RUSTFLAGS='-Zalways-encode-mir' xargo build &&
17-
cd ..
15+
xargo/build.sh
1816
- |
1917
# Test plain miri
2018
cargo build &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(alloc, allocator_api)]
2+
3+
extern crate alloc;
4+
5+
use alloc::heap::Heap;
6+
use alloc::allocator::*;
7+
8+
// error-pattern: tried to deallocate or reallocate using incorrect alignment or size
9+
10+
use alloc::heap::*;
11+
fn main() {
12+
unsafe {
13+
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
14+
// Try realloc with a too big alignment.
15+
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 2), Layout::from_size_align_unchecked(1, 1)).unwrap();
16+
}
17+
}

tests/compile-fail/reallocate-bad-alignment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use alloc::heap::*;
1111
fn main() {
1212
unsafe {
1313
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 2)).unwrap();
14+
// Try realloc with a too small alignment.
1415
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 2)).unwrap();
1516
}
1617
}

xargo/build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd "$(readlink -e "$(dirname "$0")")"
3+
RUSTFLAGS='-Zalways-encode-mir' xargo build

0 commit comments

Comments
 (0)