提交 3f3fadae 编写于 作者: R Ralf Jung 提交者: GitHub

Merge pull request #301 from RalfJung/mir-validate

More validation tests
......@@ -10,6 +10,7 @@ before_script:
- cargo install xargo
- export RUST_SYSROOT=$HOME/rust
script:
- set -e
- |
# get ourselves a MIR-ful libstd
xargo/build.sh
......
#![allow(unused_variables)]
// For some reason, the error location is different when using fullmir
// error-pattern: in conflict with lock WriteLock
mod safe {
use std::slice::from_raw_parts_mut;
pub fn as_mut_slice<T>(self_: &Vec<T>) -> &mut [T] {
unsafe {
from_raw_parts_mut(self_.as_ptr() as *mut T, self_.len())
}
}
}
fn main() {
let v = vec![0,1,2];
let v1_ = safe::as_mut_slice(&v);
let v2_ = safe::as_mut_slice(&v);
}
trait Id {
type Out;
fn id(self) -> Self::Out;
}
impl<'a> Id for &'a mut i32 {
type Out = &'a mut i32;
fn id(self) -> Self { self }
}
impl<'a> Id for &'a mut u32 {
type Out = &'a mut u32;
fn id(self) -> Self { self }
}
fn foo<T>(mut x: T) where for<'a> &'a mut T: Id
{
let x = &mut x;
let _y = x.id();
// Inspecting the trace should show that _y has a type involving a local lifetime, when it gets validated.
// Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right
// type. Currently, this is NOT working correctly; see <https://github.com/solson/miri/issues/298>.
}
fn main() {
foo(3)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册