about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-06-07 22:51:00 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-06-07 22:51:00 -0700
commitcdcae39ba37b212d4f85e251082205cedc6b38ef (patch)
tree63654831459b9b964818231083ccf81fb4c5092b /src/libsyntax/ext
parentfd85239119ffba1c57a493603d63deed9be60521 (diff)
downloadrust-cdcae39ba37b212d4f85e251082205cedc6b38ef.tar.gz
rust-cdcae39ba37b212d4f85e251082205cedc6b38ef.zip
syntax: Remove some more implicit copies
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/source_util.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index 99b928cfb9c..0680194ea6b 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -34,8 +34,9 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
 fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                _body: ast::mac_body) -> @ast::expr {
     get_mac_args(cx, sp, arg, 0u, option::some(0u), "file");
-    let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo);
-    ret make_new_lit(cx, sp, ast::lit_str(loc.file.name));
+    let { file: @{ name: filename, _ }, _ } =
+        codemap::lookup_char_pos(cx.codemap(), sp.lo);
+    ret make_new_lit(cx, sp, ast::lit_str(filename));
 }
 
 fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
@@ -66,12 +67,15 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
 
     let file = expr_to_str(cx, args[0], "#include_str requires a string");
 
-    alt io::read_whole_file_str(res_rel_file(cx, sp, file)) {
-      result::ok(src) { ret make_new_lit(cx, sp, ast::lit_str(src)); }
+    let res = io::read_whole_file_str(res_rel_file(cx, sp, file));
+    alt res {
+      result::ok(_) { /* Continue. */ }
       result::err(e) {
-        cx.parse_sess().span_diagnostic.handler().fatal(e)
+        cx.parse_sess().span_diagnostic.handler().fatal(e);
       }
     }
+
+    ret make_new_lit(cx, sp, ast::lit_str(result::unwrap(res)));
 }
 
 fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
@@ -93,7 +97,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
     }
 }
 
-fn res_rel_file(cx: ext_ctxt, sp: codemap::span, arg: path) -> path {
+fn res_rel_file(cx: ext_ctxt, sp: codemap::span, +arg: path) -> path {
     // NB: relative paths are resolved relative to the compilation unit
     if !path::path_is_absolute(arg) {
         let cu = codemap::span_to_filename(sp, cx.codemap());