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.
This commit is contained in:
commit
f6c9ff392b
@ -740,7 +740,7 @@ pub fn new_mark(m:Mrk, tail:SyntaxContext) -> SyntaxContext {
|
||||
}
|
||||
|
||||
// Extend a syntax context with a given mark and table
|
||||
// FIXME #4536 : currently pub to allow testing
|
||||
// FIXME #8215 : currently pub to allow testing
|
||||
pub fn new_mark_internal(m:Mrk, tail:SyntaxContext,table:&mut SCTable)
|
||||
-> SyntaxContext {
|
||||
let key = (tail,m);
|
||||
@ -769,7 +769,7 @@ pub fn new_rename(id:Ident, to:Name, tail:SyntaxContext) -> SyntaxContext {
|
||||
}
|
||||
|
||||
// Extend a syntax context with a given rename and sctable
|
||||
// FIXME #4536 : currently pub to allow testing
|
||||
// FIXME #8215 : currently pub to allow testing
|
||||
pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SCTable)
|
||||
-> SyntaxContext {
|
||||
let key = (tail,id,to);
|
||||
@ -792,7 +792,7 @@ pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SC
|
||||
|
||||
/// Make a fresh syntax context table with EmptyCtxt in slot zero
|
||||
/// and IllegalCtxt in slot one.
|
||||
// FIXME #4536 : currently pub to allow testing
|
||||
// FIXME #8215 : currently pub to allow testing
|
||||
pub fn new_sctable_internal() -> SCTable {
|
||||
SCTable {
|
||||
table: ~[EmptyCtxt,IllegalCtxt],
|
||||
@ -834,7 +834,7 @@ pub fn mtwt_resolve(id : Ident) -> Name {
|
||||
resolve_internal(id, get_sctable(), get_resolve_table())
|
||||
}
|
||||
|
||||
// FIXME #4536: must be pub for testing
|
||||
// FIXME #8215: must be pub for testing
|
||||
pub type ResolveTable = HashMap<(Name,SyntaxContext),Name>;
|
||||
|
||||
// okay, I admit, putting this in TLS is not so nice:
|
||||
@ -853,7 +853,7 @@ pub fn get_resolve_table() -> @mut ResolveTable {
|
||||
|
||||
// Resolve a syntax object to a name, per MTWT.
|
||||
// adding memoization to possibly resolve 500+ seconds in resolve for librustc (!)
|
||||
// FIXME #4536 : currently pub to allow testing
|
||||
// FIXME #8215 : currently pub to allow testing
|
||||
pub fn resolve_internal(id : Ident,
|
||||
table : &mut SCTable,
|
||||
resolve_table : &mut ResolveTable) -> Name {
|
||||
|
@ -1640,9 +1640,10 @@ mod test {
|
||||
macro_rules! user(($x:ident) => ({letty!($x); $x}))
|
||||
fn main() -> int {user!(z)}",
|
||||
~[~[0]], false),
|
||||
// FIXME #8062: this test exposes a *potential* bug; our system does
|
||||
// not behave exactly like MTWT, but I haven't thought of a way that
|
||||
// this could cause a bug in Rust, yet.
|
||||
// no longer a fixme #8062: this test exposes a *potential* bug; our system does
|
||||
// not behave exactly like MTWT, but a conversation with Matthew Flatt
|
||||
// suggests that this can only occur in the presence of local-expand, which
|
||||
// we have no plans to support.
|
||||
// ("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",
|
||||
// ~[~[0]], true)
|
||||
// FIXME #6994: the next string exposes the bug referred to in issue 6994, so I'm
|
||||
@ -1655,6 +1656,7 @@ mod test {
|
||||
// fn a(){g!(z)}"
|
||||
// create a really evil test case where a $x appears inside a binding of $x
|
||||
// but *shouldnt* bind because it was inserted by a different macro....
|
||||
// can't write this test case until we have macro-generating macros.
|
||||
];
|
||||
for (idx,s) in tests.iter().enumerate() {
|
||||
run_renaming_test(s,idx);
|
||||
|
@ -875,7 +875,6 @@ fn consume_whitespace(rdr: @mut StringReader) {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use ast;
|
||||
use codemap::{BytePos, CodeMap, Span};
|
||||
use diagnostic;
|
||||
use parse::token;
|
||||
|
@ -324,17 +324,10 @@ mod test {
|
||||
use abi;
|
||||
use parse::parser::Parser;
|
||||
use parse::token::{str_to_ident};
|
||||
use util::parser_testing::{string_to_tts_and_sess, string_to_parser};
|
||||
use util::parser_testing::{string_to_tts, string_to_parser};
|
||||
use util::parser_testing::{string_to_expr, string_to_item};
|
||||
use util::parser_testing::string_to_stmt;
|
||||
|
||||
// map a string to tts, return the tt without its parsesess
|
||||
fn string_to_tts_only(source_str : @str) -> ~[ast::token_tree] {
|
||||
let (tts,_ps) = string_to_tts_and_sess(source_str);
|
||||
tts
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)] fn to_json_str<E : Encodable<extra::json::Encoder>>(val: @E) -> ~str {
|
||||
do io::with_str_writer |writer| {
|
||||
let mut encoder = extra::json::Encoder(writer);
|
||||
@ -395,8 +388,53 @@ mod test {
|
||||
string_to_expr(@"::abc::def::return");
|
||||
}
|
||||
|
||||
// check the token-tree-ization of macros
|
||||
#[test] fn string_to_tts_macro () {
|
||||
let tts = string_to_tts(@"macro_rules! zip (($a)=>($a))");
|
||||
match tts {
|
||||
[ast::tt_tok(_,_),
|
||||
ast::tt_tok(_,token::NOT),
|
||||
ast::tt_tok(_,_),
|
||||
ast::tt_delim(delim_elts)] =>
|
||||
match *delim_elts {
|
||||
[ast::tt_tok(_,token::LPAREN),
|
||||
ast::tt_delim(first_set),
|
||||
ast::tt_tok(_,token::FAT_ARROW),
|
||||
ast::tt_delim(second_set),
|
||||
ast::tt_tok(_,token::RPAREN)] =>
|
||||
match *first_set {
|
||||
[ast::tt_tok(_,token::LPAREN),
|
||||
ast::tt_tok(_,token::DOLLAR),
|
||||
ast::tt_tok(_,_),
|
||||
ast::tt_tok(_,token::RPAREN)] =>
|
||||
match *second_set {
|
||||
[ast::tt_tok(_,token::LPAREN),
|
||||
ast::tt_tok(_,token::DOLLAR),
|
||||
ast::tt_tok(_,_),
|
||||
ast::tt_tok(_,token::RPAREN)] =>
|
||||
assert_eq!("correct","correct"),
|
||||
_ => assert_eq!("wrong 4","correct")
|
||||
},
|
||||
_ => {
|
||||
error!("failing value 3: %?",first_set);
|
||||
assert_eq!("wrong 3","correct")
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
error!("failing value 2: %?",delim_elts);
|
||||
assert_eq!("wrong","correct");
|
||||
}
|
||||
|
||||
},
|
||||
_ => {
|
||||
error!("failing value: %?",tts);
|
||||
assert_eq!("wrong 1","correct");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test] fn string_to_tts_1 () {
|
||||
let (tts,_ps) = string_to_tts_and_sess(@"fn a (b : int) { b; }");
|
||||
let tts = string_to_tts(@"fn a (b : int) { b; }");
|
||||
assert_eq!(to_json_str(@tts),
|
||||
~"[\
|
||||
{\
|
||||
|
@ -2035,6 +2035,11 @@ impl Parser {
|
||||
|
||||
// parse a single token tree from the input.
|
||||
pub fn parse_token_tree(&self) -> token_tree {
|
||||
// FIXME #6994: currently, this is too eager. It
|
||||
// parses token trees but also identifies tt_seq's
|
||||
// and tt_nonterminals; it's too early to know yet
|
||||
// whether something will be a nonterminal or a seq
|
||||
// yet.
|
||||
maybe_whole!(deref self, nt_tt);
|
||||
|
||||
// this is the fall-through for the 'match' below.
|
||||
|
Loading…
x
Reference in New Issue
Block a user