rustc now can use integer literals in attributes
This commit is contained in:
parent
35e8882553
commit
f5a89d297c
5 changed files with 15 additions and 15 deletions
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(custom_attribute)]
|
||||
#![miri(stack_limit="2")]
|
||||
#![feature(custom_attribute, attr_literals)]
|
||||
#![miri(stack_limit=2)]
|
||||
|
||||
fn bar() {
|
||||
foo();
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue