Skip to content

Commit 3f3fada

Browse files
authored
Merge pull request rust-lang#301 from RalfJung/mir-validate
More validation tests
2 parents 66108be + ae10b23 commit 3f3fada

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ before_script:
1010
- cargo install xargo
1111
- export RUST_SYSROOT=$HOME/rust
1212
script:
13+
- set -e
1314
- |
1415
# get ourselves a MIR-ful libstd
1516
xargo/build.sh
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![allow(unused_variables)]
2+
3+
// For some reason, the error location is different when using fullmir
4+
// error-pattern: in conflict with lock WriteLock
5+
6+
mod safe {
7+
use std::slice::from_raw_parts_mut;
8+
9+
pub fn as_mut_slice<T>(self_: &Vec<T>) -> &mut [T] {
10+
unsafe {
11+
from_raw_parts_mut(self_.as_ptr() as *mut T, self_.len())
12+
}
13+
}
14+
}
15+
16+
fn main() {
17+
let v = vec![0,1,2];
18+
let v1_ = safe::as_mut_slice(&v);
19+
let v2_ = safe::as_mut_slice(&v);
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
trait Id {
2+
type Out;
3+
4+
fn id(self) -> Self::Out;
5+
}
6+
7+
impl<'a> Id for &'a mut i32 {
8+
type Out = &'a mut i32;
9+
10+
fn id(self) -> Self { self }
11+
}
12+
13+
impl<'a> Id for &'a mut u32 {
14+
type Out = &'a mut u32;
15+
16+
fn id(self) -> Self { self }
17+
}
18+
19+
fn foo<T>(mut x: T) where for<'a> &'a mut T: Id
20+
{
21+
let x = &mut x;
22+
let _y = x.id();
23+
// Inspecting the trace should show that _y has a type involving a local lifetime, when it gets validated.
24+
// Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right
25+
// type. Currently, this is NOT working correctly; see <https://github.com/solson/miri/issues/298>.
26+
}
27+
28+
fn main() {
29+
foo(3)
30+
}

0 commit comments

Comments
 (0)