Skip to content

Commit f6c9ff3

Browse files
committed
auto merge of #9481 : jbclements/rust/minor-cleanup, r=cmr
Small stuff... might as well get it into the tree. One new test case, some issue # cleanup, remove some unused imports.
2 parents 4531184 + 0269850 commit f6c9ff3

File tree

5 files changed

+62
-18
lines changed

5 files changed

+62
-18
lines changed

src/libsyntax/ast_util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ pub fn new_mark(m:Mrk, tail:SyntaxContext) -> SyntaxContext {
740740
}
741741

742742
// Extend a syntax context with a given mark and table
743-
// FIXME #4536 : currently pub to allow testing
743+
// FIXME #8215 : currently pub to allow testing
744744
pub fn new_mark_internal(m:Mrk, tail:SyntaxContext,table:&mut SCTable)
745745
-> SyntaxContext {
746746
let key = (tail,m);
@@ -769,7 +769,7 @@ pub fn new_rename(id:Ident, to:Name, tail:SyntaxContext) -> SyntaxContext {
769769
}
770770
771771
// Extend a syntax context with a given rename and sctable
772-
// FIXME #4536 : currently pub to allow testing
772+
// FIXME #8215 : currently pub to allow testing
773773
pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SCTable)
774774
-> SyntaxContext {
775775
let key = (tail,id,to);
@@ -792,7 +792,7 @@ pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SC
792792
793793
/// Make a fresh syntax context table with EmptyCtxt in slot zero
794794
/// and IllegalCtxt in slot one.
795-
// FIXME #4536 : currently pub to allow testing
795+
// FIXME #8215 : currently pub to allow testing
796796
pub fn new_sctable_internal() -> SCTable {
797797
SCTable {
798798
table: ~[EmptyCtxt,IllegalCtxt],
@@ -834,7 +834,7 @@ pub fn mtwt_resolve(id : Ident) -> Name {
834834
resolve_internal(id, get_sctable(), get_resolve_table())
835835
}
836836
837-
// FIXME #4536: must be pub for testing
837+
// FIXME #8215: must be pub for testing
838838
pub type ResolveTable = HashMap<(Name,SyntaxContext),Name>;
839839
840840
// okay, I admit, putting this in TLS is not so nice:
@@ -853,7 +853,7 @@ pub fn get_resolve_table() -> @mut ResolveTable {
853853
854854
// Resolve a syntax object to a name, per MTWT.
855855
// adding memoization to possibly resolve 500+ seconds in resolve for librustc (!)
856-
// FIXME #4536 : currently pub to allow testing
856+
// FIXME #8215 : currently pub to allow testing
857857
pub fn resolve_internal(id : Ident,
858858
table : &mut SCTable,
859859
resolve_table : &mut ResolveTable) -> Name {

src/libsyntax/ext/expand.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,10 @@ mod test {
16401640
macro_rules! user(($x:ident) => ({letty!($x); $x}))
16411641
fn main() -> int {user!(z)}",
16421642
~[~[0]], false),
1643-
// FIXME #8062: this test exposes a *potential* bug; our system does
1644-
// not behave exactly like MTWT, but I haven't thought of a way that
1645-
// this could cause a bug in Rust, yet.
1643+
// no longer a fixme #8062: this test exposes a *potential* bug; our system does
1644+
// not behave exactly like MTWT, but a conversation with Matthew Flatt
1645+
// suggests that this can only occur in the presence of local-expand, which
1646+
// we have no plans to support.
16461647
// ("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",
16471648
// ~[~[0]], true)
16481649
// FIXME #6994: the next string exposes the bug referred to in issue 6994, so I'm
@@ -1655,6 +1656,7 @@ mod test {
16551656
// fn a(){g!(z)}"
16561657
// create a really evil test case where a $x appears inside a binding of $x
16571658
// but *shouldnt* bind because it was inserted by a different macro....
1659+
// can't write this test case until we have macro-generating macros.
16581660
];
16591661
for (idx,s) in tests.iter().enumerate() {
16601662
run_renaming_test(s,idx);

src/libsyntax/parse/lexer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ fn consume_whitespace(rdr: @mut StringReader) {
875875
mod test {
876876
use super::*;
877877

878-
use ast;
879878
use codemap::{BytePos, CodeMap, Span};
880879
use diagnostic;
881880
use parse::token;

src/libsyntax/parse/mod.rs

+47-9
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,10 @@ mod test {
324324
use abi;
325325
use parse::parser::Parser;
326326
use parse::token::{str_to_ident};
327-
use util::parser_testing::{string_to_tts_and_sess, string_to_parser};
327+
use util::parser_testing::{string_to_tts, string_to_parser};
328328
use util::parser_testing::{string_to_expr, string_to_item};
329329
use util::parser_testing::string_to_stmt;
330330

331-
// map a string to tts, return the tt without its parsesess
332-
fn string_to_tts_only(source_str : @str) -> ~[ast::token_tree] {
333-
let (tts,_ps) = string_to_tts_and_sess(source_str);
334-
tts
335-
}
336-
337-
338331
#[cfg(test)] fn to_json_str<E : Encodable<extra::json::Encoder>>(val: @E) -> ~str {
339332
do io::with_str_writer |writer| {
340333
let mut encoder = extra::json::Encoder(writer);
@@ -395,8 +388,53 @@ mod test {
395388
string_to_expr(@"::abc::def::return");
396389
}
397390

391+
// check the token-tree-ization of macros
392+
#[test] fn string_to_tts_macro () {
393+
let tts = string_to_tts(@"macro_rules! zip (($a)=>($a))");
394+
match tts {
395+
[ast::tt_tok(_,_),
396+
ast::tt_tok(_,token::NOT),
397+
ast::tt_tok(_,_),
398+
ast::tt_delim(delim_elts)] =>
399+
match *delim_elts {
400+
[ast::tt_tok(_,token::LPAREN),
401+
ast::tt_delim(first_set),
402+
ast::tt_tok(_,token::FAT_ARROW),
403+
ast::tt_delim(second_set),
404+
ast::tt_tok(_,token::RPAREN)] =>
405+
match *first_set {
406+
[ast::tt_tok(_,token::LPAREN),
407+
ast::tt_tok(_,token::DOLLAR),
408+
ast::tt_tok(_,_),
409+
ast::tt_tok(_,token::RPAREN)] =>
410+
match *second_set {
411+
[ast::tt_tok(_,token::LPAREN),
412+
ast::tt_tok(_,token::DOLLAR),
413+
ast::tt_tok(_,_),
414+
ast::tt_tok(_,token::RPAREN)] =>
415+
assert_eq!("correct","correct"),
416+
_ => assert_eq!("wrong 4","correct")
417+
},
418+
_ => {
419+
error!("failing value 3: %?",first_set);
420+
assert_eq!("wrong 3","correct")
421+
}
422+
},
423+
_ => {
424+
error!("failing value 2: %?",delim_elts);
425+
assert_eq!("wrong","correct");
426+
}
427+
428+
},
429+
_ => {
430+
error!("failing value: %?",tts);
431+
assert_eq!("wrong 1","correct");
432+
}
433+
}
434+
}
435+
398436
#[test] fn string_to_tts_1 () {
399-
let (tts,_ps) = string_to_tts_and_sess(@"fn a (b : int) { b; }");
437+
let tts = string_to_tts(@"fn a (b : int) { b; }");
400438
assert_eq!(to_json_str(@tts),
401439
~"[\
402440
{\

src/libsyntax/parse/parser.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,11 @@ impl Parser {
20352035

20362036
// parse a single token tree from the input.
20372037
pub fn parse_token_tree(&self) -> token_tree {
2038+
// FIXME #6994: currently, this is too eager. It
2039+
// parses token trees but also identifies tt_seq's
2040+
// and tt_nonterminals; it's too early to know yet
2041+
// whether something will be a nonterminal or a seq
2042+
// yet.
20382043
maybe_whole!(deref self, nt_tt);
20392044

20402045
// this is the fall-through for the 'match' below.

0 commit comments

Comments
 (0)