diff options
| author | Kevin Ballard <kevin@sb.org> | 2013-09-26 17:21:59 -0700 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2013-10-15 21:56:54 -0700 |
| commit | 73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef (patch) | |
| tree | 7050b2b93e3c58d7766e9aecd7e973ea88d9210e /src/libsyntax/ext/source_util.rs | |
| parent | 6741241f4046aea4014b1a23618593fb481c8606 (diff) | |
| download | rust-73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef.tar.gz rust-73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef.zip | |
path2: Replace the path module outright
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.
Diffstat (limited to 'src/libsyntax/ext/source_util.rs')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index e76ade0dc3d..ef09315a887 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -81,7 +81,7 @@ pub fn expand_include(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) let file = get_single_str_from_tts(cx, sp, tts, "include!"); let p = parse::new_sub_parser_from_file( cx.parse_sess(), cx.cfg(), - &res_rel_file(cx, sp, &Path(file)), sp); + &res_rel_file(cx, sp, &Path::from_str(file)), sp); base::MRExpr(p.parse_expr()) } @@ -89,7 +89,7 @@ pub fn expand_include(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); - let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file))); + let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path::from_str(file))); match res { result::Ok(res) => { base::MRExpr(cx.expr_str(sp, res.to_managed())) @@ -103,7 +103,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); - match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { + match io::read_whole_file(&res_rel_file(cx, sp, &Path::from_str(file))) { result::Ok(src) => { let u8_exprs: ~[@ast::Expr] = src.iter().map(|char| cx.expr_u8(sp, *char)).collect(); base::MRExpr(cx.expr_vec(sp, u8_exprs)) @@ -144,10 +144,12 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { // isn't already) fn res_rel_file(cx: @ExtCtxt, sp: codemap::Span, arg: &Path) -> Path { // NB: relative paths are resolved relative to the compilation unit - if !arg.is_absolute { - let cu = Path(cx.codemap().span_to_filename(sp)); - cu.dir_path().push_many(arg.components) + if !arg.is_absolute() { + let mut cu = Path::from_str(cx.codemap().span_to_filename(sp)); + cu.pop(); + cu.push_path(arg); + cu } else { - (*arg).clone() + arg.clone() } } |
