diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-08-24 15:28:43 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-08-24 15:51:16 -0700 |
| commit | c284b8b1dc348ab8b9c82350dd1b4e53fac1225c (patch) | |
| tree | 99de39b149969275f6f9ddebd7a9f555d91c5bff /src/libsyntax/ext | |
| parent | a8f1bee4574b8427a052e2fad93a90839288584b (diff) | |
| download | rust-c284b8b1dc348ab8b9c82350dd1b4e53fac1225c.tar.gz rust-c284b8b1dc348ab8b9c82350dd1b4e53fac1225c.zip | |
Start using core::path2::Path in a lot of places.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index b74a1165b79..881691b5f5c 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -59,7 +59,7 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"include"); let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), - res_rel_file(cx, sp, file), + &res_rel_file(cx, sp, &Path(file)), parse::parser::SOURCE_FILE); return p.parse_expr(); } @@ -70,7 +70,7 @@ 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"); - let res = io::read_whole_file_str(res_rel_file(cx, sp, file)); + let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file))); match res { result::ok(_) => { /* Continue. */ } result::err(e) => { @@ -87,7 +87,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); - match io::read_whole_file(res_rel_file(cx, sp, file)) { + match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { result::ok(src) => { let u8_exprs = vec::map(src, |char: u8| { mk_u8(cx, sp, char) @@ -100,14 +100,13 @@ 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()); - let dir = path::dirname(cu); - return path::connect(dir, arg); + if !arg.is_absolute { + let cu = Path(codemap::span_to_filename(sp, cx.codemap())); + cu.dir_path().push_many(arg.components) } else { - return arg; + copy *arg } } |
