diff options
| author | bors <bors@rust-lang.org> | 2014-05-08 09:06:42 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-08 09:06:42 -0700 |
| commit | aa6725407ae0a2cb88458e147e76adf8bcae0961 (patch) | |
| tree | c09983e00886791c40b9304d99dd8d05e2d613c2 /src/libsyntax/parse/mod.rs | |
| parent | e45485181338137136ea2816d78ed108440f7d50 (diff) | |
| parent | 7f8f3dcf179d7b771f8e9c588ab081ab5eb9c394 (diff) | |
| download | rust-aa6725407ae0a2cb88458e147e76adf8bcae0961.tar.gz rust-aa6725407ae0a2cb88458e147e76adf8bcae0961.zip | |
auto merge of #14032 : pcwalton/rust/detildestr, r=alexcrichton
r? @brson
Diffstat (limited to 'src/libsyntax/parse/mod.rs')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index dec6e6dd374..28f235a3da0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -77,8 +77,8 @@ pub fn parse_crate_attrs_from_file( inner } -pub fn parse_crate_from_source_str(name: ~str, - source: ~str, +pub fn parse_crate_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> ast::Crate { @@ -89,8 +89,8 @@ pub fn parse_crate_from_source_str(name: ~str, maybe_aborted(p.parse_crate_mod(),p) } -pub fn parse_crate_attrs_from_source_str(name: ~str, - source: ~str, +pub fn parse_crate_attrs_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> Vec<ast::Attribute> { @@ -102,8 +102,8 @@ pub fn parse_crate_attrs_from_source_str(name: ~str, inner } -pub fn parse_expr_from_source_str(name: ~str, - source: ~str, +pub fn parse_expr_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> @ast::Expr { @@ -111,8 +111,8 @@ pub fn parse_expr_from_source_str(name: ~str, maybe_aborted(p.parse_expr(), p) } -pub fn parse_item_from_source_str(name: ~str, - source: ~str, +pub fn parse_item_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> Option<@ast::Item> { @@ -121,8 +121,8 @@ pub fn parse_item_from_source_str(name: ~str, maybe_aborted(p.parse_item(attrs),p) } -pub fn parse_meta_from_source_str(name: ~str, - source: ~str, +pub fn parse_meta_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> @ast::MetaItem { @@ -130,8 +130,8 @@ pub fn parse_meta_from_source_str(name: ~str, maybe_aborted(p.parse_meta_item(),p) } -pub fn parse_stmt_from_source_str(name: ~str, - source: ~str, +pub fn parse_stmt_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, attrs: Vec<ast::Attribute> , sess: &ParseSess) @@ -145,8 +145,8 @@ pub fn parse_stmt_from_source_str(name: ~str, maybe_aborted(p.parse_stmt(attrs),p) } -pub fn parse_tts_from_source_str(name: ~str, - source: ~str, +pub fn parse_tts_from_source_str(name: StrBuf, + source: StrBuf, cfg: ast::CrateConfig, sess: &ParseSess) -> Vec<ast::TokenTree> { @@ -164,8 +164,8 @@ pub fn parse_tts_from_source_str(name: ~str, // Create a new parser from a source string pub fn new_parser_from_source_str<'a>(sess: &'a ParseSess, cfg: ast::CrateConfig, - name: ~str, - source: ~str) + name: StrBuf, + source: StrBuf) -> Parser<'a> { filemap_to_parser(sess, string_to_filemap(sess, source, name), cfg) } @@ -225,8 +225,8 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) }; match str::from_utf8(bytes.as_slice()) { Some(s) => { - return string_to_filemap(sess, s.to_owned(), - path.as_str().unwrap().to_str()) + return string_to_filemap(sess, s.to_strbuf(), + path.as_str().unwrap().to_strbuf()) } None => err(format!("{} is not UTF-8 encoded", path.display())), } @@ -235,7 +235,7 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) // given a session and a string, add the string to // the session's codemap and return the new filemap -pub fn string_to_filemap(sess: &ParseSess, source: ~str, path: ~str) +pub fn string_to_filemap(sess: &ParseSess, source: StrBuf, path: StrBuf) -> Rc<FileMap> { sess.span_diagnostic.cm.new_filemap(path, source) } @@ -284,11 +284,11 @@ mod test { use util::parser_testing::{string_to_expr, string_to_item}; use util::parser_testing::string_to_stmt; - fn to_json_str<'a, E: Encodable<json::Encoder<'a>, io::IoError>>(val: &E) -> ~str { + fn to_json_str<'a, E: Encodable<json::Encoder<'a>, io::IoError>>(val: &E) -> StrBuf { let mut writer = MemWriter::new(); let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer); let _ = val.encode(&mut encoder); - str::from_utf8(writer.unwrap().as_slice()).unwrap().to_owned() + str::from_utf8(writer.unwrap().as_slice()).unwrap().to_strbuf() } // produce a codemap::span @@ -297,7 +297,7 @@ mod test { } #[test] fn path_exprs_1() { - assert!(string_to_expr("a".to_owned()) == + assert!(string_to_expr("a".to_strbuf()) == @ast::Expr{ id: ast::DUMMY_NODE_ID, node: ast::ExprPath(ast::Path { @@ -316,7 +316,7 @@ mod test { } #[test] fn path_exprs_2 () { - assert!(string_to_expr("::a::b".to_owned()) == + assert!(string_to_expr("::a::b".to_strbuf()) == @ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprPath(ast::Path { @@ -341,12 +341,12 @@ mod test { #[should_fail] #[test] fn bad_path_expr_1() { - string_to_expr("::abc::def::return".to_owned()); + string_to_expr("::abc::def::return".to_strbuf()); } // check the token-tree-ization of macros #[test] fn string_to_tts_macro () { - let tts = string_to_tts("macro_rules! zip (($a)=>($a))".to_owned()); + let tts = string_to_tts("macro_rules! zip (($a)=>($a))".to_strbuf()); let tts: &[ast::TokenTree] = tts.as_slice(); match tts { [ast::TTTok(_,_), @@ -399,7 +399,7 @@ mod test { } #[test] fn string_to_tts_1 () { - let tts = string_to_tts("fn a (b : int) { b; }".to_owned()); + let tts = string_to_tts("fn a (b : int) { b; }".to_strbuf()); assert_eq!(to_json_str(&tts), "[\ {\ @@ -523,12 +523,12 @@ mod test { ]\ ]\ }\ -]".to_owned() +]".to_strbuf() ); } #[test] fn ret_expr() { - assert!(string_to_expr("return d".to_owned()) == + assert!(string_to_expr("return d".to_strbuf()) == @ast::Expr{ id: ast::DUMMY_NODE_ID, node:ast::ExprRet(Some(@ast::Expr{ @@ -551,7 +551,7 @@ mod test { } #[test] fn parse_stmt_1 () { - assert!(string_to_stmt("b;".to_owned()) == + assert!(string_to_stmt("b;".to_strbuf()) == @Spanned{ node: ast::StmtExpr(@ast::Expr { id: ast::DUMMY_NODE_ID, @@ -578,7 +578,7 @@ mod test { #[test] fn parse_ident_pat () { let sess = new_parse_sess(); - let mut parser = string_to_parser(&sess, "b".to_owned()); + let mut parser = string_to_parser(&sess, "b".to_strbuf()); assert!(parser.parse_pat() == @ast::Pat{id: ast::DUMMY_NODE_ID, node: ast::PatIdent( @@ -602,7 +602,7 @@ mod test { // check the contents of the tt manually: #[test] fn parse_fundecl () { // this test depends on the intern order of "fn" and "int" - assert!(string_to_item("fn a (b : int) { b; }".to_owned()) == + assert!(string_to_item("fn a (b : int) { b; }".to_strbuf()) == Some( @ast::Item{ident:str_to_ident("a"), attrs:Vec::new(), @@ -694,13 +694,13 @@ mod test { #[test] fn parse_exprs () { // just make sure that they parse.... - string_to_expr("3 + 4".to_owned()); - string_to_expr("a::z.froob(b,@(987+3))".to_owned()); + string_to_expr("3 + 4".to_strbuf()); + string_to_expr("a::z.froob(b,@(987+3))".to_strbuf()); } #[test] fn attrs_fix_bug () { string_to_item("pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) - -> Result<@Writer, ~str> { + -> Result<@Writer, StrBuf> { #[cfg(windows)] fn wb() -> c_int { (O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int @@ -710,7 +710,7 @@ mod test { fn wb() -> c_int { O_WRONLY as c_int } let mut fflags: c_int = wb(); -}".to_owned()); +}".to_strbuf()); } } |
