Skip to content

Commit 68bf48e

Browse files
committed
auto merge of #10166 : brson/rust/meta, r=alexcrichton
This doesn't fix #623 but works around it by limiting the grammar.
2 parents c888fc6 + 6ef1ab9 commit 68bf48e

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/libsyntax/parse/attr.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ impl parser_attr for Parser {
161161
token::EQ => {
162162
self.bump();
163163
let lit = self.parse_lit();
164+
// FIXME #623 Non-string meta items are not serialized correctly;
165+
// just forbid them for now
166+
match lit.node {
167+
ast::lit_str(*) => (),
168+
_ => {
169+
self.span_err(
170+
lit.span,
171+
"non-string literals are not allowed in meta-items");
172+
}
173+
}
164174
let hi = self.span.hi;
165175
@spanned(lo, hi, ast::MetaNameValue(name, lit))
166176
}

src/test/compile-fail/non-str-meta.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Issue #623 - non-string meta items are not serialized correctly;
12+
// for now just forbid them
13+
14+
#[foo = 1] //~ ERROR: non-string literals are not allowed in meta-items
15+
fn main() { }

src/test/run-pass/item-attributes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ mod test_foreign_items {
174174
}
175175
}
176176

177-
mod test_literals {
177+
178+
// FIXME #623 - these aren't supported yet
179+
/*mod test_literals {
178180
#[str = "s"];
179181
#[char = 'c'];
180182
#[int = 100];
@@ -185,7 +187,7 @@ mod test_literals {
185187
#[nil = ()];
186188
#[bool = true];
187189
mod m {}
188-
}
190+
}*/
189191

190192
fn test_fn_inner() {
191193
#[inner_fn_attr];

0 commit comments

Comments
 (0)