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/util | |
| 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/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 24 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index d705da7b72b..7f856845722 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -92,7 +92,7 @@ impl<T: TotalEq + Hash + Clone + 'static> Interner<T> { #[deriving(Clone, Eq, Hash, Ord)] pub struct RcStr { - string: Rc<~str>, + string: Rc<StrBuf>, } impl TotalEq for RcStr {} @@ -106,7 +106,7 @@ impl TotalOrd for RcStr { impl Str for RcStr { #[inline] fn as_slice<'a>(&'a self) -> &'a str { - let s: &'a str = *self.string; + let s: &'a str = self.string.as_slice(); s } } @@ -121,7 +121,7 @@ impl fmt::Show for RcStr { impl RcStr { pub fn new(string: &str) -> RcStr { RcStr { - string: Rc::new(string.to_owned()), + string: Rc::new(string.to_strbuf()), } } } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index cdf7455b1bc..359a8537b2b 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -16,17 +16,21 @@ use parse::parser::Parser; use parse::token; // map a string to tts, using a made-up filename: -pub fn string_to_tts(source_str: ~str) -> Vec<ast::TokenTree> { +pub fn string_to_tts(source_str: StrBuf) -> Vec<ast::TokenTree> { let ps = new_parse_sess(); - filemap_to_tts(&ps, string_to_filemap(&ps, source_str,"bogofile".to_owned())) + filemap_to_tts(&ps, + string_to_filemap(&ps, source_str, "bogofile".to_strbuf())) } // map string to parser (via tts) -pub fn string_to_parser<'a>(ps: &'a ParseSess, source_str: ~str) -> Parser<'a> { - new_parser_from_source_str(ps, Vec::new(), "bogofile".to_owned(), source_str) +pub fn string_to_parser<'a>(ps: &'a ParseSess, source_str: StrBuf) -> Parser<'a> { + new_parser_from_source_str(ps, + Vec::new(), + "bogofile".to_strbuf(), + source_str) } -fn with_error_checking_parse<T>(s: ~str, f: |&mut Parser| -> T) -> T { +fn with_error_checking_parse<T>(s: StrBuf, f: |&mut Parser| -> T) -> T { let ps = new_parse_sess(); let mut p = string_to_parser(&ps, s); let x = f(&mut p); @@ -35,28 +39,28 @@ fn with_error_checking_parse<T>(s: ~str, f: |&mut Parser| -> T) -> T { } // parse a string, return a crate. -pub fn string_to_crate (source_str : ~str) -> ast::Crate { +pub fn string_to_crate (source_str : StrBuf) -> ast::Crate { with_error_checking_parse(source_str, |p| { p.parse_crate_mod() }) } // parse a string, return an expr -pub fn string_to_expr (source_str : ~str) -> @ast::Expr { +pub fn string_to_expr (source_str : StrBuf) -> @ast::Expr { with_error_checking_parse(source_str, |p| { p.parse_expr() }) } // parse a string, return an item -pub fn string_to_item (source_str : ~str) -> Option<@ast::Item> { +pub fn string_to_item (source_str : StrBuf) -> Option<@ast::Item> { with_error_checking_parse(source_str, |p| { p.parse_item(Vec::new()) }) } // parse a string, return a stmt -pub fn string_to_stmt(source_str : ~str) -> @ast::Stmt { +pub fn string_to_stmt(source_str : StrBuf) -> @ast::Stmt { with_error_checking_parse(source_str, |p| { p.parse_stmt(Vec::new()) }) @@ -64,7 +68,7 @@ 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 { +pub fn string_to_pat(source_str: StrBuf) -> @ast::Pat { string_to_parser(&new_parse_sess(), source_str).parse_pat() } |
