Skip to content

Commit 5adfa1d

Browse files
authored
Merge pull request #698 from RalfJung/stacked-borrows-2
test that creating a 2nd mutable ref from a NonNull invalidates the first
2 parents 7d7cf4d + 22b57f6 commit 5adfa1d

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ install:
3030
build_script:
3131
- set RUST_TEST_NOCAPTURE=1
3232
- set RUST_BACKTRACE=1
33+
- set RUSTFLAGS=-C debug-assertions
3334
# Build and install miri
3435
- cargo build --release --all-features --all-targets
3536
- cargo install --all-features --force --path .

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ os:
1212
- osx
1313
dist: xenial
1414

15+
env:
16+
global:
17+
- RUST_TEST_NOCAPTURE=1
18+
- RUST_BACKTRACE=1
19+
- RUSTFLAGS="-C debug-assertions"
20+
1521
before_script:
1622
# Linux: install extra stuff for cross-compilation
1723
- if [[ "$TRAVIS_OS_NAME" == linux ]]; then sudo apt update && sudo apt install gcc-multilib; fi
@@ -48,7 +54,3 @@ notifications:
4854
branches:
4955
only:
5056
- master
51-
env:
52-
global:
53-
- RUST_TEST_NOCAPTURE=1
54-
- RUST_BACKTRACE=1

src/bin/cargo-miri.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(inner_deref)]
22

3-
extern crate cargo_metadata;
4-
53
use std::fs::{self, File};
64
use std::io::{self, Write, BufRead};
75
use std::path::{PathBuf, Path};

test-cargo-miri/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
extern crate byteorder;
2-
#[cfg(test)]
3-
extern crate rand;
4-
51
use byteorder::{BigEndian, ByteOrder};
62

73
fn main() {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use std::ptr::NonNull;
2+
3+
fn main() { unsafe {
4+
let x = &mut 0;
5+
let mut ptr1 = NonNull::from(x);
6+
let mut ptr2 = ptr1.clone();
7+
let raw1 = ptr1.as_mut();
8+
let _raw2 = ptr2.as_mut();
9+
let _val = *raw1; //~ ERROR borrow stack
10+
} }

0 commit comments

Comments
 (0)