add env var emulation test, and fix it complaining about leaks
This commit is contained in:
parent
b84f7e2029
commit
348f782085
11
src/lib.rs
11
src/lib.rs
@ -215,11 +215,22 @@ pub enum MiriMemoryKind {
|
||||
}
|
||||
|
||||
impl Into<MemoryKind<MiriMemoryKind>> for MiriMemoryKind {
|
||||
#[inline(always)]
|
||||
fn into(self) -> MemoryKind<MiriMemoryKind> {
|
||||
MemoryKind::Machine(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl MayLeak for MiriMemoryKind {
|
||||
#[inline(always)]
|
||||
fn may_leak(self) -> bool {
|
||||
use MiriMemoryKind::*;
|
||||
match self {
|
||||
Rust | C => false,
|
||||
Env | MutStatic => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Evaluator<'tcx> {
|
||||
|
7
tests/run-pass/env.rs
Normal file
7
tests/run-pass/env.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
|
||||
env::set_var("MIRI_TEST", "the answer");
|
||||
assert_eq!(env::var("MIRI_TEST"), Ok("the answer".to_owned()));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user