diff options
| author | Kevin Ballard <kevin@sb.org> | 2013-10-05 19:49:32 -0700 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2013-10-15 22:18:30 -0700 |
| commit | d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd (patch) | |
| tree | e197783b86700e71d94c9bc6d0254eb25b16cc0c /src/libsyntax | |
| parent | ed539e14712539473c3e89604cb69e2307110772 (diff) | |
| download | rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.tar.gz rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.zip | |
path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index ef09315a887..c7ac3e1da9e 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::from_str(file)), sp); + &res_rel_file(cx, sp, &Path::new(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::from_str(file))); + let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path::new(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::from_str(file))) { + match io::read_whole_file(&res_rel_file(cx, sp, &Path::new(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)) @@ -145,7 +145,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { 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 mut cu = Path::from_str(cx.codemap().span_to_filename(sp)); + let mut cu = Path::new(cx.codemap().span_to_filename(sp)); cu.pop(); cu.push_path(arg); cu diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ad565fd2ec4..32cd45c86cb 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3992,20 +3992,20 @@ impl Parser { outer_attrs: &[ast::Attribute], id_sp: Span) -> (ast::item_, ~[ast::Attribute]) { - let mut prefix = Path::from_str(self.sess.cm.span_to_filename(*self.span)); + let mut prefix = Path::new(self.sess.cm.span_to_filename(*self.span)); prefix.pop(); let mod_path_stack = &*self.mod_path_stack; - let mod_path = Path::from_str(".").join_many_str(*mod_path_stack); + let mod_path = Path::new(".").join_many(*mod_path_stack); let dir_path = prefix.join_path(&mod_path); let file_path = match ::attr::first_attr_value_str_by_name( outer_attrs, "path") { - Some(d) => dir_path.join_str(d), + Some(d) => dir_path.join(d), None => { let mod_name = token::interner_get(id.name).to_owned(); let default_path_str = mod_name + ".rs"; let secondary_path_str = mod_name + "/mod.rs"; - let default_path = dir_path.join_str(default_path_str); - let secondary_path = dir_path.join_str(secondary_path_str); + let default_path = dir_path.join(default_path_str.as_slice()); + let secondary_path = dir_path.join(secondary_path_str.as_slice()); let default_exists = default_path.exists(); let secondary_exists = secondary_path.exists(); match (default_exists, secondary_exists) { |
