diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 15a970586b80..cc0132e4090d 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -41,12 +41,12 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { let mut memory_size = 100*1024*1024; // 100MB let mut step_limit = 1000_000; let mut stack_limit = 100; - fn extract_str(lit: &syntax::ast::Lit) -> syntax::parse::token::InternedString { + let extract_int = |lit: &syntax::ast::Lit| -> u64 { match lit.node { - syntax::ast::LitKind::Str(ref s, _) => s.clone(), - _ => bug!("attribute values need to be strings"), + syntax::ast::LitKind::Int(i, _) => i, + _ => state.session.span_fatal(lit.span, "expected an integer literal"), } - } + }; for attr in krate.attrs.iter() { match attr.node.value.node { MetaItemKind::List(ref name, _) if name != "miri" => {} @@ -55,9 +55,9 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { NestedMetaItemKind::MetaItem(ref inner) => match inner.node { MetaItemKind::NameValue(ref name, ref value) => { match &**name { - "memory_size" => memory_size = extract_str(value).parse().expect("not a number"), - "step_limit" => step_limit = extract_str(value).parse().expect("not a number"), - "stack_limit" => stack_limit = extract_str(value).parse().expect("not a number"), + "memory_size" => memory_size = extract_int(value) as usize, + "step_limit" => step_limit = extract_int(value), + "stack_limit" => stack_limit = extract_int(value) as usize, _ => state.session.span_err(item.span, "unknown miri attribute"), } } diff --git a/tests/compile-fail/oom.rs b/tests/compile-fail/oom.rs index 83109a77e620..d3911a65f2f3 100644 --- a/tests/compile-fail/oom.rs +++ b/tests/compile-fail/oom.rs @@ -1,5 +1,5 @@ -#![feature(custom_attribute)] -#![miri(memory_size="0")] +#![feature(custom_attribute, attr_literals)] +#![miri(memory_size=0)] fn bar() { let x = 5; diff --git a/tests/compile-fail/oom2.rs b/tests/compile-fail/oom2.rs index 63c51dbaa7d2..d0344e4faeb3 100644 --- a/tests/compile-fail/oom2.rs +++ b/tests/compile-fail/oom2.rs @@ -1,5 +1,5 @@ -#![feature(custom_attribute)] -#![miri(memory_size="1000")] +#![feature(custom_attribute, attr_literals)] +#![miri(memory_size=1000)] fn bar(i: i32) { if i < 1000 { diff --git a/tests/compile-fail/stack_limit.rs b/tests/compile-fail/stack_limit.rs index 3b6d4186dc90..2a78fbe5398f 100644 --- a/tests/compile-fail/stack_limit.rs +++ b/tests/compile-fail/stack_limit.rs @@ -1,5 +1,5 @@ -#![feature(custom_attribute)] -#![miri(stack_limit="2")] +#![feature(custom_attribute, attr_literals)] +#![miri(stack_limit=2)] fn bar() { foo(); diff --git a/tests/compile-fail/timeout.rs b/tests/compile-fail/timeout.rs index bcb6c993089a..edd4c3186691 100644 --- a/tests/compile-fail/timeout.rs +++ b/tests/compile-fail/timeout.rs @@ -1,6 +1,6 @@ //error-pattern: reached the configured maximum execution time -#![feature(custom_attribute)] -#![miri(step_limit="1000")] +#![feature(custom_attribute, attr_literals)] +#![miri(step_limit=1000)] fn main() { for i in 0..1000000 {