Skip to content

Commit 5f57a50

Browse files
committed
Convert misc compiler bits to istrs. Issue #855
1 parent cffd9b8 commit 5f57a50

File tree

12 files changed

+93
-91
lines changed

12 files changed

+93
-91
lines changed

src/comp/driver/rustc.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ fn default_configuration(sess: session::session,
4747
ast::crate_cfg {
4848
let libc =
4949
alt sess.get_targ_cfg().os {
50-
session::os_win32. { "msvcrt.dll" }
51-
session::os_macos. { "libc.dylib" }
52-
session::os_linux. { "libc.so.6" }
53-
_ { "libc.so" }
50+
session::os_win32. { ~"msvcrt.dll" }
51+
session::os_macos. { ~"libc.dylib" }
52+
session::os_linux. { ~"libc.so.6" }
53+
_ { ~"libc.so" }
5454
};
5555

5656
let mk = attr::mk_name_value_item_str;
5757

5858
ret [ // Target bindings.
59-
mk(~"target_os", istr::to_estr(std::os::target_os())),
60-
mk(~"target_arch", "x86"),
59+
mk(~"target_os", std::os::target_os()),
60+
mk(~"target_arch", ~"x86"),
6161
mk(~"target_libc", libc),
6262
// Build bindings.
63-
mk(~"build_compiler", istr::to_estr(argv0)),
64-
mk(~"build_input", istr::to_estr(input))];
63+
mk(~"build_compiler", argv0),
64+
mk(~"build_input", input)];
6565
}
6666

6767
fn build_configuration(sess: session::session, argv0: &istr, input: &istr) ->

src/comp/front/attr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ fn span<@T>(item: &T) -> ast::spanned<T> {
197197
ret {node: item, span: ast_util::dummy_sp()};
198198
}
199199

200-
fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {
201-
let value_lit = span(ast::lit_str(istr::from_estr(value), ast::sk_rc));
200+
fn mk_name_value_item_str(name: ast::ident,
201+
value: &istr) -> @ast::meta_item {
202+
let value_lit = span(ast::lit_str(value, ast::sk_rc));
202203
ret mk_name_value_item(name, value_lit);
203204
}
204205

src/comp/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
310310
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
311311
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
312312
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
313-
let v = str::unsafe_from_bytes(ebml::doc_data(vd));
313+
let v = istr::unsafe_from_bytes(ebml::doc_data(vd));
314314
// FIXME (#611): Should be able to decode meta_name_value variants,
315315
// but currently they can't be encoded
316316
items += [attr::mk_name_value_item_str(n, v)];

src/comp/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] {
511511

512512
let name_item =
513513
attr::mk_name_value_item_str(
514-
~"name", istr::to_estr(ecx.ccx.link_meta.name));
514+
~"name", ecx.ccx.link_meta.name);
515515
let vers_item =
516516
attr::mk_name_value_item_str(
517-
~"vers", istr::to_estr(ecx.ccx.link_meta.vers));
517+
~"vers", ecx.ccx.link_meta.vers);
518518

519519
let other_items =
520520
{

src/comp/middle/kind.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,44 +112,45 @@ fn type_and_kind(tcx: &ty::ctxt, e: &@ast::expr) ->
112112
}
113113

114114
fn need_expr_kind(tcx: &ty::ctxt, e: &@ast::expr, k_need: ast::kind,
115-
descr: &str) {
115+
descr: &istr) {
116116
let tk = type_and_kind(tcx, e);
117-
log #fmt["for %s: want %s type, got %s type %s", descr,
117+
log #fmt["for %s: want %s type, got %s type %s", istr::to_estr(descr),
118118
kind_to_str(k_need), kind_to_str(tk.kind),
119119
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
120120

121121
if !kind_lteq(k_need, tk.kind) {
122122
let s =
123123
#fmt["mismatched kinds for %s: needed %s type, got %s type %s",
124-
descr, kind_to_str(k_need), kind_to_str(tk.kind),
124+
istr::to_estr(descr), kind_to_str(k_need),
125+
kind_to_str(tk.kind),
125126
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
126127
tcx.sess.span_err(e.span, istr::from_estr(s));
127128
}
128129
}
129130

130131
fn need_shared_lhs_rhs(tcx: &ty::ctxt, a: &@ast::expr, b: &@ast::expr,
131-
op: &str) {
132-
need_expr_kind(tcx, a, ast::kind_shared, op + " lhs");
133-
need_expr_kind(tcx, b, ast::kind_shared, op + " rhs");
132+
op: &istr) {
133+
need_expr_kind(tcx, a, ast::kind_shared, op + ~" lhs");
134+
need_expr_kind(tcx, b, ast::kind_shared, op + ~" rhs");
134135
}
135136

136137
fn check_expr(tcx: &ty::ctxt, e: &@ast::expr) {
137138
alt e.node {
138-
ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, "<-"); }
139-
ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, "="); }
140-
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); }
141-
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
139+
ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"<-"); }
140+
ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"="); }
141+
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, ~"op="); }
142+
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"<->"); }
142143
ast::expr_copy(a) {
143-
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
144+
need_expr_kind(tcx, a, ast::kind_shared, ~"'copy' operand");
144145
}
145146
ast::expr_ret(option::some(a)) {
146-
need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand");
147+
need_expr_kind(tcx, a, ast::kind_shared, ~"'ret' operand");
147148
}
148149
ast::expr_be(a) {
149-
need_expr_kind(tcx, a, ast::kind_shared, "'be' operand");
150+
need_expr_kind(tcx, a, ast::kind_shared, ~"'be' operand");
150151
}
151152
ast::expr_fail(option::some(a)) {
152-
need_expr_kind(tcx, a, ast::kind_shared, "'fail' operand");
153+
need_expr_kind(tcx, a, ast::kind_shared, ~"'fail' operand");
153154
}
154155
ast::expr_call(callee, _) {
155156
let tpt = ty::expr_ty_params_and_ty(tcx, callee);

src/comp/middle/trans_alt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ fn variant_opt(ccx: &@crate_ctxt, pat_id: ast::node_id) -> opt {
5858
}
5959

6060
type bind_map = [{ident: ast::ident, val: ValueRef}];
61-
fn assoc(key: str, list: &bind_map) -> option::t<ValueRef> {
61+
fn assoc(key: &istr, list: &bind_map) -> option::t<ValueRef> {
6262
for elt: {ident: ast::ident, val: ValueRef} in list {
63-
if istr::eq(elt.ident, istr::from_estr(key)) { ret some(elt.val); }
63+
if istr::eq(elt.ident, key) { ret some(elt.val); }
6464
}
6565
ret none;
6666
}
@@ -304,7 +304,7 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
304304
// the actual arm block.
305305
for each @{key, val} in data.id_map.items() {
306306
bcx.fcx.lllocals.insert
307-
(val, option::get(assoc(istr::to_estr(key),
307+
(val, option::get(assoc(key,
308308
m[0].bound)));
309309
}
310310
let {bcx: guard_bcx, val: guard_val} =
@@ -474,7 +474,7 @@ fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node],
474474
let vals = [];
475475
for ex: exit_node in map {
476476
if ex.to as uint == our_block {
477-
alt assoc(istr::to_estr(item.key), ex.bound) {
477+
alt assoc(item.key, ex.bound) {
478478
some(val) { llbbs += [ex.from]; vals += [val]; }
479479
none. { }
480480
}

src/comp/middle/ty.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
243243
// Never construct these manually. These are interned.
244244
type raw_t =
245245
{struct: sty,
246-
cname: option::t<str>,
246+
cname: option::t<istr>,
247247
hash: uint,
248248
has_params: bool,
249249
has_vars: bool};
@@ -427,8 +427,8 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map,
427427

428428

429429
// Type constructors
430-
fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<str>) -> @raw_t {
431-
let cname = none;
430+
fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<istr>) -> @raw_t {
431+
let cname: option::t<istr> = none;
432432
let h = hash_type_info(st, cname);
433433
let has_params: bool = false;
434434
let has_vars: bool = false;
@@ -505,11 +505,11 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<str>) -> @raw_t {
505505
has_vars: has_vars};
506506
}
507507

508-
fn intern(cx: &ctxt, st: &sty, cname: &option::t<str>) {
508+
fn intern(cx: &ctxt, st: &sty, cname: &option::t<istr>) {
509509
interner::intern(*cx.ts, mk_raw_ty(cx, st, cname));
510510
}
511511

512-
fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t<str>) -> t {
512+
fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t<istr>) -> t {
513513
let raw_type = mk_raw_ty(cx, st, cname);
514514
ret interner::intern(*cx.ts, raw_type);
515515
}
@@ -617,7 +617,7 @@ fn struct(cx: &ctxt, typ: t) -> sty {
617617

618618

619619
// Returns the canonical name of the given type.
620-
fn cname(cx: &ctxt, typ: t) -> option::t<str> {
620+
fn cname(cx: &ctxt, typ: t) -> option::t<istr> {
621621
ret interner::get(*cx.ts, typ).cname;
622622
}
623623

@@ -794,7 +794,7 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t {
794794

795795
// Type utilities
796796

797-
fn rename(cx: &ctxt, typ: t, new_cname: str) -> t {
797+
fn rename(cx: &ctxt, typ: t, new_cname: &istr) -> t {
798798
ret gen_ty_full(cx, struct(cx, typ), some(new_cname));
799799
}
800800

@@ -1538,11 +1538,11 @@ fn hash_type_structure(st: &sty) -> uint {
15381538
}
15391539
}
15401540

1541-
fn hash_type_info(st: &sty, cname_opt: &option::t<str>) -> uint {
1541+
fn hash_type_info(st: &sty, cname_opt: &option::t<istr>) -> uint {
15421542
let h = hash_type_structure(st);
15431543
alt cname_opt {
15441544
none. {/* no-op */ }
1545-
some(s) { h += h << 5u + str::hash(s); }
1545+
some(s) { h += h << 5u + istr::hash(s); }
15461546
}
15471547
ret h;
15481548
}
@@ -1606,7 +1606,7 @@ fn eq_raw_ty(a: &@raw_t, b: &@raw_t) -> bool {
16061606
none. { alt b.cname { none. {/* ok */ } _ { ret false; } } }
16071607
some(s_a) {
16081608
alt b.cname {
1609-
some(s_b) { if !str::eq(s_a, s_b) { ret false; } }
1609+
some(s_b) { if !istr::eq(s_a, s_b) { ret false; } }
16101610
_ { ret false; }
16111611
}
16121612
}

src/comp/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) ->
417417
alt cname {
418418
none. {/* no-op */ }
419419
some(cname_str) {
420-
typ = ty::rename(tcx, typ, istr::to_estr(cname_str));
420+
typ = ty::rename(tcx, typ, cname_str);
421421
}
422422
}
423423
tcx.ast_ty_to_ty_cache.insert(ast_ty, some(typ));
@@ -629,7 +629,7 @@ mod collect {
629629
ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty {
630630
let methods = get_obj_method_types(cx, ob);
631631
let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
632-
t_obj = ty::rename(cx.tcx, t_obj, istr::to_estr(id));
632+
t_obj = ty::rename(cx.tcx, t_obj, id);
633633
ret {kinds: ty_param_kinds(ty_params), ty: t_obj};
634634
}
635635
fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj,

src/comp/syntax/ext/env.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
2828

2929
let var = expr_to_str(cx, args[0], ~"#env requires a string");
3030
alt generic_os::getenv(var) {
31-
option::none. { ret make_new_str(cx, sp, ""); }
31+
option::none. { ret make_new_str(cx, sp, ~""); }
3232
option::some(s) {
33-
ret make_new_str(cx, sp, istr::to_estr(s));
33+
ret make_new_str(cx, sp, s);
3434
}
3535
}
3636
}
3737

38-
fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: str) -> @ast::expr {
39-
ret make_new_lit(cx, sp, ast::lit_str(istr::from_estr(s), ast::sk_rc));
38+
fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: &istr) -> @ast::expr {
39+
ret make_new_lit(cx, sp, ast::lit_str(s, ast::sk_rc));
4040
}
4141
//
4242
// Local Variables:

0 commit comments

Comments
 (0)