summary refs log tree commit diff
path: root/src/libsyntax/parse/mod.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-13 03:02:55 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-13 10:20:52 +1000
commit096f6f56a8178bd7f4b69a2ea909838e782766fb (patch)
tree37513f0d39fdfb4d5a702a72abd7423c93c51cdf /src/libsyntax/parse/mod.rs
parent641910dc1340b7786fd758282bac88639a58ddcd (diff)
downloadrust-096f6f56a8178bd7f4b69a2ea909838e782766fb.tar.gz
rust-096f6f56a8178bd7f4b69a2ea909838e782766fb.zip
Use @str instead of @~str in libsyntax and librustc. Fixes #5048.
This almost removes the StringRef wrapper, since all strings are
Equiv-alent now. Removes a lot of `/* bad */ copy *`'s, and converts
several things to be &'static str (the lint table and the intrinsics
table).

There are many instances of .to_managed(), unfortunately.
Diffstat (limited to 'src/libsyntax/parse/mod.rs')
-rw-r--r--src/libsyntax/parse/mod.rs80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 559bca34f21..5edd2ec4d47 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -82,38 +82,38 @@ pub fn parse_crate_from_file(
 }
 
 pub fn parse_crate_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     sess: @mut ParseSess
 ) -> @ast::crate {
     let p = new_parser_from_source_str(
         sess,
         /*bad*/ copy cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     maybe_aborted(p.parse_crate_mod(),p)
 }
 
 pub fn parse_expr_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     sess: @mut ParseSess
 ) -> @ast::expr {
     let p = new_parser_from_source_str(
         sess,
         cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     maybe_aborted(p.parse_expr(), p)
 }
 
 pub fn parse_item_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     attrs: ~[ast::attribute],
     sess: @mut ParseSess
@@ -121,30 +121,30 @@ pub fn parse_item_from_source_str(
     let p = new_parser_from_source_str(
         sess,
         cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     maybe_aborted(p.parse_item(attrs),p)
 }
 
 pub fn parse_meta_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     sess: @mut ParseSess
 ) -> @ast::meta_item {
     let p = new_parser_from_source_str(
         sess,
         cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     maybe_aborted(p.parse_meta_item(),p)
 }
 
 pub fn parse_stmt_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     attrs: ~[ast::attribute],
     sess: @mut ParseSess
@@ -152,22 +152,22 @@ pub fn parse_stmt_from_source_str(
     let p = new_parser_from_source_str(
         sess,
         cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     maybe_aborted(p.parse_stmt(attrs),p)
 }
 
 pub fn parse_tts_from_source_str(
-    name: ~str,
-    source: @~str,
+    name: @str,
+    source: @str,
     cfg: ast::crate_cfg,
     sess: @mut ParseSess
 ) -> ~[ast::token_tree] {
     let p = new_parser_from_source_str(
         sess,
         cfg,
-        /*bad*/ copy name,
+        name,
         source
     );
     *p.quote_depth += 1u;
@@ -182,8 +182,8 @@ pub fn parse_tts_from_source_str(
 // result.
 pub fn parse_from_source_str<T>(
     f: &fn(&Parser) -> T,
-    name: ~str, ss: codemap::FileSubstr,
-    source: @~str,
+    name: @str, ss: codemap::FileSubstr,
+    source: @str,
     cfg: ast::crate_cfg,
     sess: @mut ParseSess
 ) -> T {
@@ -213,8 +213,8 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id {
 // Create a new parser from a source string
 pub fn new_parser_from_source_str(sess: @mut ParseSess,
                                   cfg: ast::crate_cfg,
-                                  name: ~str,
-                                  source: @~str)
+                                  name: @str,
+                                  source: @str)
                                -> Parser {
     filemap_to_parser(sess,string_to_filemap(sess,source,name),cfg)
 }
@@ -223,9 +223,9 @@ pub fn new_parser_from_source_str(sess: @mut ParseSess,
 // is specified as a substring of another file.
 pub fn new_parser_from_source_substr(sess: @mut ParseSess,
                                   cfg: ast::crate_cfg,
-                                  name: ~str,
+                                  name: @str,
                                   ss: codemap::FileSubstr,
-                                  source: @~str)
+                                  source: @str)
                                -> Parser {
     filemap_to_parser(sess,substring_to_filemap(sess,source,name,ss),cfg)
 }
@@ -275,7 +275,7 @@ pub fn new_parser_from_tts(sess: @mut ParseSess,
 pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<span>)
     -> @FileMap {
     match io::read_whole_file_str(path) {
-        Ok(src) => string_to_filemap(sess, @src, path.to_str()),
+        Ok(src) => string_to_filemap(sess, src.to_managed(), path.to_str().to_managed()),
         Err(e) => {
             match spanopt {
                 Some(span) => sess.span_diagnostic.span_fatal(span, e),
@@ -287,14 +287,14 @@ pub fn file_to_filemap(sess: @mut 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: @mut ParseSess, source: @~str, path: ~str)
+pub fn string_to_filemap(sess: @mut ParseSess, source: @str, path: @str)
     -> @FileMap {
     sess.cm.new_filemap(path, source)
 }
 
 // given a session and a string and a path and a FileSubStr, add
 // the string to the CodeMap and return the new FileMap
-pub fn substring_to_filemap(sess: @mut ParseSess, source: @~str, path: ~str,
+pub fn substring_to_filemap(sess: @mut ParseSess, source: @str, path: @str,
                            filesubstr: FileSubstr) -> @FileMap {
     sess.cm.new_filemap_w_substr(path,filesubstr,source)
 }
@@ -349,7 +349,7 @@ mod test {
     use util::parser_testing::{string_to_stmt, strs_to_idents};
 
     // map a string to tts, return the tt without its parsesess
-    fn string_to_tts_only(source_str : @~str) -> ~[ast::token_tree] {
+    fn string_to_tts_only(source_str : @str) -> ~[ast::token_tree] {
         let (tts,_ps) = string_to_tts_and_sess(source_str);
         tts
     }
@@ -368,7 +368,7 @@ mod test {
     }
 
     #[test] fn path_exprs_1 () {
-        assert_eq!(string_to_expr(@~"a"),
+        assert_eq!(string_to_expr(@"a"),
                    @ast::expr{id:1,
                               node:ast::expr_path(@ast::Path {span:sp(0,1),
                                                               global:false,
@@ -379,7 +379,7 @@ mod test {
     }
 
     #[test] fn path_exprs_2 () {
-        assert_eq!(string_to_expr(@~"::a::b"),
+        assert_eq!(string_to_expr(@"::a::b"),
                    @ast::expr{id:1,
                                node:ast::expr_path(
                                    @ast::Path {span:sp(0,6),
@@ -394,11 +394,11 @@ mod test {
     // marked as `#[should_fail]`.
     /*#[should_fail]
     #[test] fn bad_path_expr_1() {
-        string_to_expr(@~"::abc::def::return");
+        string_to_expr(@"::abc::def::return");
     }*/
 
     #[test] fn string_to_tts_1 () {
-        let (tts,_ps) = string_to_tts_and_sess(@~"fn a (b : int) { b; }");
+        let (tts,_ps) = string_to_tts_and_sess(@"fn a (b : int) { b; }");
         assert_eq!(to_json_str(@tts),
                    ~"[\
                 [\"tt_tok\",null,[\"IDENT\",\"fn\",false]],\
@@ -427,7 +427,7 @@ mod test {
     }
 
     #[test] fn ret_expr() {
-        assert_eq!(string_to_expr(@~"return d"),
+        assert_eq!(string_to_expr(@"return d"),
                    @ast::expr{id:2,
                               node:ast::expr_ret(
                                   Some(@ast::expr{id:1,
@@ -443,7 +443,7 @@ mod test {
     }
 
     #[test] fn parse_stmt_1 () {
-        assert_eq!(string_to_stmt(@~"b;"),
+        assert_eq!(string_to_stmt(@"b;"),
                    @spanned{
                        node: ast::stmt_expr(@ast::expr{
                            id: 1,
@@ -465,7 +465,7 @@ mod test {
     }
 
     #[test] fn parse_ident_pat () {
-        let parser = string_to_parser(@~"b");
+        let parser = string_to_parser(@"b");
         assert_eq!(parser.parse_pat(),
                    @ast::pat{id:1, // fixme
                              node: ast::pat_ident(ast::bind_infer,
@@ -482,7 +482,7 @@ mod test {
     }
 
     #[test] fn parse_arg () {
-        let parser = string_to_parser(@~"b : int");
+        let parser = string_to_parser(@"b : int");
         assert_eq!(parser.parse_arg_general(true),
                    ast::arg{
                        is_mutbl: false,
@@ -515,7 +515,7 @@ mod test {
     #[test] fn parse_fundecl () {
         // this test depends on the intern order of "fn" and "int", and on the
         // assignment order of the node_ids.
-        assert_eq!(string_to_item(@~"fn a (b : int) { b; }"),
+        assert_eq!(string_to_item(@"fn a (b : int) { b; }"),
                   Some(
                       @ast::item{ident:str_to_ident("a"),
                             attrs:~[],
@@ -585,12 +585,12 @@ mod test {
 
     #[test] fn parse_exprs () {
         // just make sure that they parse....
-        string_to_expr(@~"3 + 4");
-        string_to_expr(@~"a::z.froob(b,@(987+3))");
+        string_to_expr(@"3 + 4");
+        string_to_expr(@"a::z.froob(b,@(987+3))");
     }
 
     #[test] fn attrs_fix_bug () {
-        string_to_item(@~"pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
+        string_to_item(@"pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
                    -> Result<@Writer, ~str> {
     #[cfg(windows)]
     fn wb() -> c_int {