about summary refs log tree commit diff
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-02-14 20:19:27 -0800
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-02-19 10:02:51 -0800
commita2b754788d5cef4b03eee0af6137e0195ef5680c (patch)
treec17a62cdb6b0c8e23262e71e8467676a72eab4f5
parent1808d747f65e43f9a8d40b9214e1221700f026d8 (diff)
downloadrust-a2b754788d5cef4b03eee0af6137e0195ef5680c.tar.gz
rust-a2b754788d5cef4b03eee0af6137e0195ef5680c.zip
convert syntax::attr to use @~strs
-rw-r--r--src/librustc/back/link.rs4
-rw-r--r--src/librustc/driver/driver.rs22
-rw-r--r--src/librustc/driver/session.rs2
-rw-r--r--src/librustc/front/test.rs8
-rw-r--r--src/librustc/metadata/creader.rs21
-rw-r--r--src/librustc/metadata/decoder.rs8
-rw-r--r--src/librustc/metadata/encoder.rs12
-rw-r--r--src/librustc/metadata/loader.rs2
-rw-r--r--src/librustc/middle/trans/foreign.rs2
-rw-r--r--src/librustdoc/attr_parser.rs5
-rw-r--r--src/librustpkg/util.rs4
-rw-r--r--src/libsyntax/attr.rs142
-rw-r--r--src/libsyntax/ext/auto_encode.rs4
-rw-r--r--src/libsyntax/ext/expand.rs4
-rw-r--r--src/libsyntax/parse/parser.rs14
-rw-r--r--src/libsyntax/print/pprust.rs8
16 files changed, 130 insertions, 132 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 02f1877e2f9..fefd49d7815 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -466,14 +466,14 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
         let linkage_metas = attr::find_linkage_metas(c.node.attrs);
         attr::require_unique_names(sess.diagnostic(), linkage_metas);
         for linkage_metas.each |meta| {
-            if attr::get_meta_item_name(*meta) == ~"name" {
+            if *attr::get_meta_item_name(*meta) == ~"name" {
                 match attr::get_meta_item_value_str(*meta) {
                   // Changing attr would avoid the need for the copy
                   // here
                   Some(v) => { name = Some(v.to_managed()); }
                   None => cmh_items.push(*meta)
                 }
-            } else if attr::get_meta_item_name(*meta) == ~"vers" {
+            } else if *attr::get_meta_item_name(*meta) == ~"vers" {
                 match attr::get_meta_item_value_str(*meta) {
                   Some(v) => { vers = Some(v.to_managed()); }
                   None => cmh_items.push(*meta)
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index 8569415e29e..8894aad4816 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -97,16 +97,16 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
     };
 
     return ~[ // Target bindings.
-         attr::mk_word_item(str::from_slice(os::FAMILY)),
-         mk(~"target_os", tos),
-         mk(~"target_family", str::from_slice(os::FAMILY)),
-         mk(~"target_arch", arch),
-         mk(~"target_endian", end),
-         mk(~"target_word_size", wordsz),
-         mk(~"target_libc", libc),
+         attr::mk_word_item(@str::from_slice(os::FAMILY)),
+         mk(@~"target_os", @tos),
+         mk(@~"target_family", @str::from_slice(os::FAMILY)),
+         mk(@~"target_arch", @arch),
+         mk(@~"target_endian", @end),
+         mk(@~"target_word_size", @wordsz),
+         mk(@~"target_libc", @libc),
          // Build bindings.
-         mk(~"build_compiler", argv0),
-         mk(~"build_input", source_name(input))];
+         mk(@~"build_compiler", @argv0),
+         mk(@~"build_input", @source_name(input))];
 }
 
 pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
@@ -114,7 +114,7 @@ pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
     if attr::contains_name(cfg, name) {
         cfg
     } else {
-        vec::append_one(cfg, attr::mk_word_item(name))
+        vec::append_one(cfg, attr::mk_word_item(@name))
     }
 }
 
@@ -142,7 +142,7 @@ pub fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg {
     // meta_word variant.
     let mut words = ~[];
     for cfgspecs.each |s| {
-        words.push(attr::mk_word_item(/*bad*/copy *s));
+        words.push(attr::mk_word_item(@/*bad*/copy *s));
     }
     return words;
 }
diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs
index 1a299f22ec0..4d7f55584bb 100644
--- a/src/librustc/driver/session.rs
+++ b/src/librustc/driver/session.rs
@@ -310,7 +310,7 @@ pub fn building_library(req_crate_type: crate_type,
             match syntax::attr::first_attr_value_str_by_name(
                 crate.node.attrs,
                 ~"crate_type") {
-              option::Some(~"lib") => true,
+              Some(@~"lib") => true,
               _ => false
             }
         }
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index 90b83e9bd6e..9955ef4a8e9 100644
--- a/src/librustc/front/test.rs
+++ b/src/librustc/front/test.rs
@@ -57,7 +57,7 @@ pub fn modify_for_testing(sess: session::Session,
     // configuration, either with the '--test' or '--cfg test'
     // command line options.
     let should_test = attr::contains(crate.node.config,
-                                     attr::mk_word_item(~"test"));
+                                     attr::mk_word_item(@~"test"));
 
     if should_test {
         generate_test_harness(sess, crate)
@@ -111,7 +111,7 @@ fn fold_mod(cx: @mut TestCtxt,
     fn nomain(cx: @mut TestCtxt, item: @ast::item) -> @ast::item {
         if !*cx.sess.building_library {
             @ast::item{attrs: item.attrs.filtered(|attr| {
-                               attr::get_attr_name(attr) != ~"main"
+                               *attr::get_attr_name(attr) != ~"main"
                            }),.. copy *item}
         } else { item }
     }
@@ -310,7 +310,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
 
     // This attribute tells resolve to let us call unexported functions
     let resolve_unexported_attr =
-        attr::mk_attr(attr::mk_word_item(~"!resolve_unexported"));
+        attr::mk_attr(attr::mk_word_item(@~"!resolve_unexported"));
 
     let item = ast::item {
         ident: cx.sess.ident_of(~"__test"),
@@ -366,7 +366,7 @@ fn is_std(cx: &TestCtxt) -> bool {
     let is_std = {
         let items = attr::find_linkage_metas(cx.crate.node.attrs);
         match attr::last_meta_item_value_str_by_name(items, ~"name") {
-          Some(~"std") => true,
+          Some(@~"std") => true,
           _ => false
         }
     };
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index 9f642d80665..b18a52a9486 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -105,7 +105,7 @@ fn warn_if_multiple_versions(e: @mut Env,
                 diag.span_note(match_.span, ~"used here");
                 let attrs = ~[
                     attr::mk_attr(attr::mk_list_item(
-                        ~"link", /*bad*/copy *match_.metas))
+                        @~"link", /*bad*/copy *match_.metas))
                 ];
                 loader::note_linkage_attrs(e.intr, diag, attrs);
             }
@@ -133,7 +133,7 @@ fn visit_crate(e: @mut Env, c: ast::crate) {
     for link_args.each |a| {
         match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
           Some(ref linkarg) => {
-            cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
+            cstore::add_used_link_args(cstore, **linkarg);
           }
           None => {/* fallthrough */ }
         }
@@ -173,21 +173,22 @@ fn visit_item(e: @mut Env, i: @ast::item) {
                match attr::first_attr_value_str_by_name(i.attrs,
                                                         ~"link_name") {
                  Some(ref nn) => {
-                   if (*nn) == ~"" {
+                   if **nn == ~"" {
                       e.diag.span_fatal(
                           i.span,
                           ~"empty #[link_name] not allowed; use #[nolink].");
                    }
                    (/*bad*/copy *nn)
                  }
-                None => /*bad*/copy *e.intr.get(i.ident)
+                None => @/*bad*/copy *e.intr.get(i.ident)
             };
             if attr::find_attrs_by_name(i.attrs, ~"nolink").is_empty() {
                 already_added =
-                    !cstore::add_used_library(cstore, copy foreign_name);
+                    !cstore::add_used_library(cstore,
+                                              /*bad*/ copy *foreign_name);
             }
             if !link_args.is_empty() && already_added {
-                e.diag.span_fatal(i.span, ~"library '" + foreign_name +
+                e.diag.span_fatal(i.span, ~"library '" + *foreign_name +
                            ~"' already added: can't specify link_args.");
             }
           }
@@ -197,7 +198,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
         for link_args.each |a| {
             match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
               Some(ref linkarg) => {
-                cstore::add_used_link_args(cstore, *linkarg);
+                cstore::add_used_link_args(cstore, /*bad*/copy **linkarg);
               }
               None => {/* fallthrough */ }
             }
@@ -211,7 +212,7 @@ fn metas_with(+ident: ~str, +key: ~str, +metas: ~[@ast::meta_item])
     -> ~[@ast::meta_item] {
     let name_items = attr::find_meta_items_by_name(metas, key);
     if name_items.is_empty() {
-        vec::append_one(metas, attr::mk_name_value_item_str(key, ident))
+        vec::append_one(metas, attr::mk_name_value_item_str(@key, @ident))
     } else {
         metas
     }
@@ -276,9 +277,9 @@ fn resolve_crate(e: @mut Env,
             match attr::last_meta_item_value_str_by_name(load_ctxt.metas,
                                                          ~"name") {
               option::Some(ref v) => (/*bad*/copy *v),
-              option::None => /*bad*/copy *e.intr.get(ident)
+              option::None => @/*bad*/copy *e.intr.get(ident)
             };
-        let cmeta = @{name: cname, data: cdata,
+        let cmeta = @{name: /*bad*/copy *cname, data: cdata,
                       cnum_map: cnum_map, cnum: cnum};
 
         let cstore = e.cstore;
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 644cf3af0bd..c862490388d 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -962,7 +962,7 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] {
     for reader::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
         let nd = reader::get_doc(meta_item_doc, tag_meta_item_name);
         let n = str::from_bytes(reader::doc_data(nd));
-        items.push(attr::mk_word_item(n));
+        items.push(attr::mk_word_item(@n));
     };
     for reader::tagged_docs(md, tag_meta_item_name_value) |meta_item_doc| {
         let nd = reader::get_doc(meta_item_doc, tag_meta_item_name);
@@ -971,13 +971,13 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] {
         let v = str::from_bytes(reader::doc_data(vd));
         // FIXME (#623): Should be able to decode meta_name_value variants,
         // but currently the encoder just drops them
-        items.push(attr::mk_name_value_item_str(n, v));
+        items.push(attr::mk_name_value_item_str(@n, @v));
     };
     for reader::tagged_docs(md, tag_meta_item_list) |meta_item_doc| {
         let nd = reader::get_doc(meta_item_doc, tag_meta_item_name);
         let n = str::from_bytes(reader::doc_data(nd));
         let subitems = get_meta_items(meta_item_doc);
-        items.push(attr::mk_list_item(n, subitems));
+        items.push(attr::mk_list_item(@n, subitems));
     };
     return items;
 }
@@ -1073,7 +1073,7 @@ pub fn get_crate_vers(data: @~[u8]) -> ~str {
     let attrs = decoder::get_crate_attributes(data);
     return match attr::last_meta_item_value_str_by_name(
         attr::find_linkage_metas(attrs), ~"vers") {
-      Some(ref ver) => (/*bad*/copy *ver),
+      Some(ref ver) => (/*bad*/copy **ver),
       None => ~"0.0"
     };
 }
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 66ccbd97e0d..cf27c6e65f6 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -1075,11 +1075,11 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
         assert !ecx.link_meta.vers.is_empty();
 
         let name_item =
-            attr::mk_name_value_item_str(~"name",
-                                         ecx.link_meta.name.to_owned());
+            attr::mk_name_value_item_str(@~"name",
+                                         @ecx.link_meta.name.to_owned());
         let vers_item =
-            attr::mk_name_value_item_str(~"vers",
-                                         ecx.link_meta.vers.to_owned());
+            attr::mk_name_value_item_str(@~"vers",
+                                         @ecx.link_meta.vers.to_owned());
 
         let other_items =
             {
@@ -1088,7 +1088,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
             };
 
         let meta_items = vec::append(~[name_item, vers_item], other_items);
-        let link_item = attr::mk_list_item(~"link", meta_items);
+        let link_item = attr::mk_list_item(@~"link", meta_items);
 
         return attr::mk_attr(link_item);
     }
@@ -1097,7 +1097,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
     let mut found_link_attr = false;
     for crate.node.attrs.each |attr| {
         attrs.push(
-            if attr::get_attr_name(attr) != ~"link" {
+            if *attr::get_attr_name(attr) != ~"link" {
                 /*bad*/copy *attr
             } else {
                 match /*bad*/copy attr.node.value.node {
diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs
index ad19eed6992..d2650696307 100644
--- a/src/librustc/metadata/loader.rs
+++ b/src/librustc/metadata/loader.rs
@@ -147,7 +147,7 @@ pub fn crate_name_from_metas(+metas: ~[@ast::meta_item]) -> ~str {
     match vec::last_opt(name_items) {
       Some(i) => {
         match attr::get_meta_item_value_str(i) {
-          Some(ref n) => (/*bad*/copy *n),
+          Some(ref n) => /*bad*/copy **n,
           // FIXME (#2406): Probably want a warning here since the user
           // is using the wrong type of meta item.
           _ => fail!()
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index 92852930a66..4446eda64b0 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -50,7 +50,7 @@ fn abi_info(arch: session::arch) -> cabi::ABIInfo {
 pub fn link_name(ccx: @crate_ctxt, i: @ast::foreign_item) -> ~str {
     match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") {
         None => ccx.sess.str_of(i.ident),
-        option::Some(ref ln) => (/*bad*/copy *ln)
+        option::Some(ref ln) => (/*bad*/copy **ln)
     }
 }
 
diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs
index 0beb651afc4..bb9ba93cbe0 100644
--- a/src/librustdoc/attr_parser.rs
+++ b/src/librustdoc/attr_parser.rs
@@ -65,9 +65,10 @@ fn doc_metas(
 
 pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
     let link_metas = attr::find_linkage_metas(attrs);
+    let name = attr::last_meta_item_value_str_by_name(link_metas, ~"name");
 
     CrateAttrs {
-        name: attr::last_meta_item_value_str_by_name(link_metas, ~"name")
+        name: name.map(|s| copy **s)
     }
 }
 
@@ -97,7 +98,7 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() {
 
 pub fn parse_desc(attrs: ~[ast::attribute]) -> Option<~str> {
     let doc_strs = do doc_metas(attrs).filter_mapped |meta| {
-        attr::get_meta_item_value_str(*meta)
+        attr::get_meta_item_value_str(*meta).map(|s| copy **s)
     };
     if doc_strs.is_empty() {
         None
diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs
index 1ad706742a8..f2b1e41bbd1 100644
--- a/src/librustpkg/util.rs
+++ b/src/librustpkg/util.rs
@@ -81,7 +81,7 @@ fn fold_mod(_ctx: @ReadyCtx, m: ast::_mod,
     fn strip_main(item: @ast::item) -> @ast::item {
         @ast::item {
             attrs: do item.attrs.filtered |attr| {
-                attr::get_attr_name(*attr) != ~"main"
+                *attr::get_attr_name(attr) != ~"main"
             },
             .. copy *item
         }
@@ -609,7 +609,7 @@ pub fn compile_input(sysroot: Option<Path>, input: driver::input, dir: &Path,
     let mut crate_cfg = options.cfg;
 
     for cfgs.each |&cfg| {
-        crate_cfg.push(attr::mk_word_item(cfg));
+        crate_cfg.push(attr::mk_word_item(@cfg));
     }
 
     let options = @{
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 8ba232a5aa9..bbe18a7fcc0 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -29,24 +29,24 @@ use std;
 
 /* Constructors */
 
-pub fn mk_name_value_item_str(name: ~str, value: ~str)
+pub fn mk_name_value_item_str(name: @~str, value: @~str)
                            -> @ast::meta_item {
-    let value_lit = dummy_spanned(ast::lit_str(@value));
-    return mk_name_value_item(name, value_lit);
+    let value_lit = dummy_spanned(ast::lit_str(value));
+    mk_name_value_item(name, value_lit)
 }
 
-pub fn mk_name_value_item(name: ~str, +value: ast::lit)
+pub fn mk_name_value_item(name: @~str, +value: ast::lit)
         -> @ast::meta_item {
-    return @dummy_spanned(ast::meta_name_value(name, value));
+    @dummy_spanned(ast::meta_name_value(/*bad*/ copy *name, value))
 }
 
-pub fn mk_list_item(name: ~str, +items: ~[@ast::meta_item]) ->
+pub fn mk_list_item(name: @~str, +items: ~[@ast::meta_item]) ->
    @ast::meta_item {
-    return @dummy_spanned(ast::meta_list(name, items));
+    @dummy_spanned(ast::meta_list(/*bad*/ copy *name, items))
 }
 
-pub fn mk_word_item(name: ~str) -> @ast::meta_item {
-    return @dummy_spanned(ast::meta_word(name));
+pub fn mk_word_item(name: @~str) -> @ast::meta_item {
+    @dummy_spanned(ast::meta_word(/*bad*/ copy *name))
 }
 
 pub fn mk_attr(item: @ast::meta_item) -> ast::attribute {
@@ -80,9 +80,9 @@ pub fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
 pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
     if attr.node.is_sugared_doc {
         let comment = get_meta_item_value_str(@attr.node.value).get();
-        let meta = mk_name_value_item_str(~"doc",
-                                     strip_doc_comment_decoration(comment));
-        return mk_attr(meta);
+        let meta = mk_name_value_item_str(@~"doc",
+                                     @strip_doc_comment_decoration(*comment));
+        mk_attr(meta)
     } else {
         *attr
     }
@@ -90,15 +90,15 @@ pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
 
 /* Accessors */
 
-pub fn get_attr_name(attr: &ast::attribute) -> ~str {
+pub pure fn get_attr_name(attr: &ast::attribute) -> @~str {
     get_meta_item_name(@attr.node.value)
 }
 
-pub fn get_meta_item_name(meta: @ast::meta_item) -> ~str {
+pub pure fn get_meta_item_name(meta: @ast::meta_item) -> @~str {
     match meta.node {
-      ast::meta_word(ref n) => (*n),
-      ast::meta_name_value(ref n, _) => (*n),
-      ast::meta_list(ref n, _) => (*n)
+        ast::meta_word(ref n) => @/*bad*/ copy *n,
+        ast::meta_name_value(ref n, _) => @/*bad*/ copy *n,
+        ast::meta_list(ref n, _) => @/*bad*/ copy *n,
     }
 }
 
@@ -106,13 +106,15 @@ pub fn get_meta_item_name(meta: @ast::meta_item) -> ~str {
  * Gets the string value if the meta_item is a meta_name_value variant
  * containing a string, otherwise none
  */
-pub fn get_meta_item_value_str(meta: @ast::meta_item) -> Option<~str> {
+pub fn get_meta_item_value_str(meta: @ast::meta_item) -> Option<@~str> {
     match meta.node {
-        ast::meta_name_value(_, v) => match v.node {
-            ast::lit_str(s) => option::Some(*s),
-            _ => option::None
+        ast::meta_name_value(_, v) => {
+            match v.node {
+                ast::lit_str(s) => Some(s),
+                _ => None,
+            }
         },
-        _ => option::None
+        _ => None
     }
 }
 
@@ -130,11 +132,11 @@ pub fn get_meta_item_list(meta: @ast::meta_item)
  * a tuple containing the name and string value, otherwise `none`
  */
 pub fn get_name_value_str_pair(item: @ast::meta_item)
-                            -> Option<(~str, ~str)> {
+                            -> Option<(@~str, @~str)> {
     match attr::get_meta_item_value_str(item) {
-      Some(ref value) => {
+      Some(value) => {
         let name = attr::get_meta_item_name(item);
-        Some((name, (*value)))
+        Some((name, value))
       }
       None => None
     }
@@ -147,7 +149,7 @@ pub fn get_name_value_str_pair(item: @ast::meta_item)
 pub fn find_attrs_by_name(attrs: &[ast::attribute], name: &str) ->
    ~[ast::attribute] {
     do vec::filter_mapped(attrs) |a| {
-        if name == get_attr_name(a) {
+        if name == *get_attr_name(a) {
             Some(*a)
         } else {
             None
@@ -160,7 +162,7 @@ pub fn find_meta_items_by_name(metas: &[@ast::meta_item], name: &str) ->
    ~[@ast::meta_item] {
     let mut rs = ~[];
     for metas.each |mi| {
-        if name == get_meta_item_name(*mi) {
+        if name == *get_meta_item_name(*mi) {
             rs.push(*mi)
         }
     }
@@ -213,36 +215,39 @@ pub fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool {
     !find_attrs_by_name(attrs, name).is_empty()
 }
 
-pub fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str)
-                                 -> Option<~str> {
+pub fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: &str)
+                                 -> Option<@~str> {
 
     let mattrs = find_attrs_by_name(attrs, name);
-    if vec::len(mattrs) > 0u {
-        return get_meta_item_value_str(attr_meta(mattrs[0]));
+    if mattrs.len() > 0 {
+        get_meta_item_value_str(attr_meta(mattrs[0]))
+    } else {
+        None
     }
-    return option::None;
 }
 
-fn last_meta_item_by_name(items: ~[@ast::meta_item], name: ~str)
+fn last_meta_item_by_name(items: ~[@ast::meta_item], name: &str)
     -> Option<@ast::meta_item> {
 
     let items = attr::find_meta_items_by_name(items, name);
     vec::last_opt(items)
 }
 
-pub fn last_meta_item_value_str_by_name(items: ~[@ast::meta_item], name: ~str)
-                                     -> Option<~str> {
+pub fn last_meta_item_value_str_by_name(items: ~[@ast::meta_item], name: &str)
+                                     -> Option<@~str> {
 
     match last_meta_item_by_name(items, name) {
-      Some(item) => match attr::get_meta_item_value_str(item) {
-        Some(ref value) => Some((*value)),
+        Some(item) => {
+            match attr::get_meta_item_value_str(item) {
+                Some(value) => Some(value),
+                None => None
+            }
+        },
         None => None
-      },
-      None => None
     }
 }
 
-pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: ~str)
+pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
     -> Option<~[@ast::meta_item]> {
 
     match last_meta_item_by_name(items, name) {
@@ -255,20 +260,11 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: ~str)
 /* Higher-level applications */
 
 pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
-    pure fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool {
-        pure fn key(m: &ast::meta_item) -> ~str {
-            match m.node {
-              ast::meta_word(ref name) => (*name),
-              ast::meta_name_value(ref name, _) => (*name),
-              ast::meta_list(ref name, _) => (*name)
-            }
-        }
-        key(*ma) <= key(*mb)
-    }
-
     // This is sort of stupid here, converting to a vec of mutables and back
     let mut v = items;
-    std::sort::quick_sort(v, lteq);
+    do std::sort::quick_sort(v) |ma, mb| {
+        get_meta_item_name(*ma) <= get_meta_item_name(*mb)
+    }
 
     // There doesn't seem to be a more optimal way to do this
     do v.map |&m| {
@@ -282,14 +278,14 @@ pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
     }
 }
 
-pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->
+pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: &str) ->
    ~[@ast::meta_item] {
 
     return vec::filter_mapped(items, |item| {
-        if get_meta_item_name(*item) != name {
-            option::Some(*item)
+        if name != *get_meta_item_name(*item) {
+            Some(*item)
         } else {
-            option::None
+            None
         }
     });
 }
@@ -310,21 +306,21 @@ pub fn find_linkage_metas(attrs: &[ast::attribute]) -> ~[@ast::meta_item] {
 pub fn foreign_abi(attrs: ~[ast::attribute])
                 -> Either<~str, ast::foreign_abi> {
     return match attr::first_attr_value_str_by_name(attrs, ~"abi") {
-      option::None => {
-        either::Right(ast::foreign_abi_cdecl)
-      }
-      option::Some(~"rust-intrinsic") => {
-        either::Right(ast::foreign_abi_rust_intrinsic)
-      }
-      option::Some(~"cdecl") => {
-        either::Right(ast::foreign_abi_cdecl)
-      }
-      option::Some(~"stdcall") => {
-        either::Right(ast::foreign_abi_stdcall)
-      }
-      option::Some(ref t) => {
-        either::Left(~"unsupported abi: " + (*t))
-      }
+        None => {
+            Right(ast::foreign_abi_cdecl)
+        }
+        Some(@~"rust-intrinsic") => {
+            Right(ast::foreign_abi_rust_intrinsic)
+        }
+        Some(@~"cdecl") => {
+            Right(ast::foreign_abi_cdecl)
+        }
+        Some(@~"stdcall") => {
+            Right(ast::foreign_abi_stdcall)
+        }
+        Some(t) => {
+            Left(~"unsupported abi: " + *t)
+        }
     };
 }
 
@@ -371,9 +367,9 @@ pub fn require_unique_names(diagnostic: span_handler,
         let name = get_meta_item_name(*meta);
 
         // FIXME: How do I silence the warnings? --pcw (#2619)
-        if !set.insert(copy name) {
+        if !set.insert(name) {
             diagnostic.span_fatal(meta.span,
-                                  fmt!("duplicate meta item `%s`", name));
+                                  fmt!("duplicate meta item `%s`", *name));
         }
     }
 }
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 24f5d650d2b..9ceaebe6dd1 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -114,7 +114,7 @@ pub fn expand_auto_encode(
     in_items: ~[@ast::item]
 ) -> ~[@ast::item] {
     fn is_auto_encode(a: &ast::attribute) -> bool {
-        attr::get_attr_name(a) == ~"auto_encode"
+        *attr::get_attr_name(a) == ~"auto_encode"
     }
 
     fn filter_attrs(item: @ast::item) -> @ast::item {
@@ -169,7 +169,7 @@ pub fn expand_auto_decode(
     in_items: ~[@ast::item]
 ) -> ~[@ast::item] {
     fn is_auto_decode(a: &ast::attribute) -> bool {
-        attr::get_attr_name(a) == ~"auto_decode"
+        *attr::get_attr_name(a) == ~"auto_decode"
     }
 
     fn filter_attrs(item: @ast::item) -> @ast::item {
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 298eed5b735..3cecf857c91 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -102,11 +102,11 @@ pub fn expand_mod_items(exts: SyntaxExtensions, cx: ext_ctxt,
         do vec::foldr(item.attrs, ~[*item]) |attr, items| {
             let mname = attr::get_attr_name(attr);
 
-            match exts.find(&mname) {
+            match exts.find(&*mname) {
               None | Some(NormalTT(_)) | Some(ItemTT(*)) => items,
               Some(ItemDecorator(dec_fn)) => {
                   cx.bt_push(ExpandedFrom({call_site: attr.span,
-                                           callie: {name: copy mname,
+                                           callie: {name: /*bad*/ copy *mname,
                                                     span: None}}));
                   let r = dec_fn(cx, attr.span, attr.node.value, items);
                   cx.bt_pop();
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index fa51d4c29d2..a16392e1da2 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3247,11 +3247,11 @@ pub impl Parser {
         // on the mod, then we'll go and suck in another file and merge
         // its contents
         match ::attr::first_attr_value_str_by_name(outer_attrs, ~"merge") {
-            Some(ref path) => {
+            Some(path) => {
                 let prefix = Path(
                     self.sess.cm.span_to_filename(copy self.span));
                 let prefix = prefix.dir_path();
-                let path = Path((*path));
+                let path = Path(copy *path);
                 let (new_mod_item, new_attrs) = self.eval_src_mod_from_path(
                     prefix, path, ~[], id_span);
 
@@ -3280,7 +3280,7 @@ pub impl Parser {
         let file_path = match ::attr::first_attr_value_str_by_name(
             attrs, ~"path") {
 
-            Some(ref d) => (*d),
+            Some(d) => copy *d,
             None => copy *default_path
         };
         self.mod_path_stack.push(file_path)
@@ -3300,10 +3300,10 @@ pub impl Parser {
         let default_path = self.sess.interner.get(id) + ~".rs";
         let file_path = match ::attr::first_attr_value_str_by_name(
             outer_attrs, ~"path") {
-            Some(ref d) => {
-                let path = Path(*d);
+            Some(d) => {
+                let path = Path(copy *d);
                 if !path.is_absolute {
-                    mod_path.push(*d)
+                    mod_path.push(copy *d)
                 } else {
                     path
                 }
@@ -3337,7 +3337,7 @@ pub impl Parser {
 
         fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
             match ::attr::first_attr_value_str_by_name(attrs, ~"path") {
-                Some(ref d) => (*d),
+                Some(d) => copy *d,
                 None => default
             }
         }
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 40ba27c495c..a23c55e063b 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -897,7 +897,7 @@ pub fn print_attribute(s: @ps, attr: ast::attribute) {
     if attr.node.is_sugared_doc {
         let meta = attr::attr_meta(attr);
         let comment = attr::get_meta_item_value_str(meta).get();
-        word(s.s, comment);
+        word(s.s, *comment);
     } else {
         word(s.s, ~"#[");
         print_meta_item(s, @attr.node.value);
@@ -1816,14 +1816,14 @@ pub fn print_type_params(s: @ps, &&params: ~[ast::ty_param]) {
 pub fn print_meta_item(s: @ps, &&item: @ast::meta_item) {
     ibox(s, indent_unit);
     match item.node {
-      ast::meta_word(ref name) => word(s.s, (*name)),
+      ast::meta_word(ref name) => word(s.s, *name),
       ast::meta_name_value(ref name, value) => {
-        word_space(s, (*name));
+        word_space(s, *name);
         word_space(s, ~"=");
         print_literal(s, @value);
       }
       ast::meta_list(ref name, ref items) => {
-        word(s.s, (*name));
+        word(s.s, *name);
         popen(s);
         commasep(
             s,