about summary refs log tree commit diff
path: root/src/libsyntax/util/parser_testing.rs
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2014-03-09 16:54:34 +0200
committerEduard Burtescu <edy.burt@gmail.com>2014-03-17 09:53:07 +0200
commit90cbe0cad20d2736c7e7ebbffb2c2d84016f9340 (patch)
treea0bee02f6e23b5b27a4606fbed7b32cd631b3e58 /src/libsyntax/util/parser_testing.rs
parent555a239301cabeb20e45c9c3c3cf98588b8ec916 (diff)
downloadrust-90cbe0cad20d2736c7e7ebbffb2c2d84016f9340.tar.gz
rust-90cbe0cad20d2736c7e7ebbffb2c2d84016f9340.zip
De-@ ParseSess uses.
Diffstat (limited to 'src/libsyntax/util/parser_testing.rs')
-rw-r--r--src/libsyntax/util/parser_testing.rs33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs
index 03fc30e2fd7..029486412ea 100644
--- a/src/libsyntax/util/parser_testing.rs
+++ b/src/libsyntax/util/parser_testing.rs
@@ -17,32 +17,19 @@ use parse::token;
 
 use std::vec_ng::Vec;
 
-// map a string to tts, using a made-up filename: return both the TokenTree's
-// and the ParseSess
-pub fn string_to_tts_and_sess (source_str : ~str) -> (Vec<ast::TokenTree> , @ParseSess) {
-    let ps = new_parse_sess();
-    (filemap_to_tts(ps,string_to_filemap(ps,source_str,~"bogofile")),ps)
-}
-
 // map a string to tts, using a made-up filename:
-pub fn string_to_tts(source_str : ~str) -> Vec<ast::TokenTree> {
-    let (tts,_) = string_to_tts_and_sess(source_str);
-    tts
-}
-
-pub fn string_to_parser_and_sess(source_str: ~str) -> (Parser,@ParseSess) {
+pub fn string_to_tts(source_str: ~str) -> Vec<ast::TokenTree> {
     let ps = new_parse_sess();
-    (new_parser_from_source_str(ps,Vec::new(),~"bogofile",source_str),ps)
+    filemap_to_tts(&ps, string_to_filemap(&ps, source_str,~"bogofile"))
 }
 
 // map string to parser (via tts)
-pub fn string_to_parser(source_str: ~str) -> Parser {
-    let (p,_) = string_to_parser_and_sess(source_str);
-    p
+pub fn string_to_parser<'a>(ps: &'a ParseSess, source_str: ~str) -> Parser<'a> {
+    new_parser_from_source_str(ps, Vec::new(), ~"bogofile", source_str)
 }
 
 fn with_error_checking_parse<T>(s: ~str, f: |&mut Parser| -> T) -> T {
-    let mut p = string_to_parser(s);
+    let mut p = string_to_parser(&new_parse_sess(), s);
     let x = f(&mut p);
     p.abort_if_errors();
     x
@@ -55,12 +42,6 @@ pub fn string_to_crate (source_str : ~str) -> ast::Crate {
     })
 }
 
-// parse a string, return a crate and the ParseSess
-pub fn string_to_crate_and_sess (source_str : ~str) -> (ast::Crate,@ParseSess) {
-    let (mut p,ps) = string_to_parser_and_sess(source_str);
-    (p.parse_crate_mod(),ps)
-}
-
 // parse a string, return an expr
 pub fn string_to_expr (source_str : ~str) -> @ast::Expr {
     with_error_checking_parse(source_str, |p| {
@@ -84,8 +65,8 @@ pub fn string_to_stmt(source_str : ~str) -> @ast::Stmt {
 
 // parse a string, return a pat. Uses "irrefutable"... which doesn't
 // (currently) affect parsing.
-pub fn string_to_pat(source_str : ~str) -> @ast::Pat {
-    string_to_parser(source_str).parse_pat()
+pub fn string_to_pat(source_str: ~str) -> @ast::Pat {
+    string_to_parser(&new_parse_sess(), source_str).parse_pat()
 }
 
 // convert a vector of strings to a vector of ast::Ident's