Skip to content

Commit 68746cd

Browse files
committed
librustc: change driver::session::Session::str_of to return @~str
1 parent b90ccc9 commit 68746cd

28 files changed

+226
-219
lines changed

src/librustc/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str {
655655

656656
for ss.each |s| {
657657
match *s { path_name(s) | path_mod(s) => {
658-
let sani = sanitize(sess.str_of(s));
658+
let sani = sanitize(*sess.str_of(s));
659659
n += fmt!("%u%s", str::len(sani), sani);
660660
} }
661661
}

src/librustc/driver/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ pub impl Session {
253253
self.debugging_opt(no_monomorphic_collapse)
254254
}
255255

256-
fn str_of(id: ast::ident) -> ~str {
257-
/*bad*/copy *self.parse_sess.interner.get(id)
256+
fn str_of(id: ast::ident) -> @~str {
257+
self.parse_sess.interner.get(id)
258258
}
259259
fn ident_of(+st: ~str) -> ast::ident {
260260
self.parse_sess.interner.intern(@st)

src/librustc/metadata/encoder.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
104104
}
105105

106106
fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) {
107-
ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name));
107+
ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name));
108108
}
109109

110110
fn encode_impl_type_basename(ecx: @encode_ctxt, ebml_w: writer::Encoder,
111111
name: ident) {
112112
ebml_w.wr_tagged_str(tag_item_impl_type_basename,
113-
ecx.tcx.sess.str_of(name));
113+
*ecx.tcx.sess.str_of(name));
114114
}
115115

116116
pub fn encode_def_id(ebml_w: writer::Encoder, id: def_id) {
@@ -305,7 +305,7 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: writer::Encoder,
305305
ast_map::path_name(name) => (tag_path_elt_name, name)
306306
};
307307

308-
ebml_w.wr_tagged_str(tag, ecx.tcx.sess.str_of(name));
308+
ebml_w.wr_tagged_str(tag, *ecx.tcx.sess.str_of(name));
309309
}
310310

311311
do ebml_w.wr_tag(tag_path) {
@@ -333,7 +333,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder,
333333
let (ident, did) = (item.ident, item.id);
334334
debug!("(encoding info for module) ... encoding impl %s \
335335
(%?/%?)",
336-
ecx.tcx.sess.str_of(ident),
336+
*ecx.tcx.sess.str_of(ident),
337337
did,
338338
ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx
339339
.sess.parse_sess.interner));
@@ -353,15 +353,15 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder,
353353
match ecx.reexports2.find(&id) {
354354
Some(ref exports) => {
355355
debug!("(encoding info for module) found reexports for %d", id);
356-
for (*exports).each |exp| {
356+
for exports.each |exp| {
357357
debug!("(encoding info for module) reexport '%s' for %d",
358-
exp.name, id);
358+
*exp.name, id);
359359
ebml_w.start_tag(tag_items_data_item_reexport);
360360
ebml_w.start_tag(tag_items_data_item_reexport_def_id);
361361
ebml_w.wr_str(def_to_str(exp.def_id));
362362
ebml_w.end_tag();
363363
ebml_w.start_tag(tag_items_data_item_reexport_name);
364-
ebml_w.wr_str(exp.name);
364+
ebml_w.wr_str(*exp.name);
365365
ebml_w.end_tag();
366366
ebml_w.end_tag();
367367
}
@@ -447,7 +447,7 @@ fn encode_info_for_struct(ecx: @encode_ctxt, ebml_w: writer::Encoder,
447447
global_index.push({val: id, pos: ebml_w.writer.tell()});
448448
ebml_w.start_tag(tag_items_data_item);
449449
debug!("encode_info_for_struct: doing %s %d",
450-
tcx.sess.str_of(nm), id);
450+
*tcx.sess.str_of(nm), id);
451451
encode_visibility(ebml_w, vis);
452452
encode_name(ecx, ebml_w, nm);
453453
encode_path(ecx, ebml_w, path, ast_map::path_name(nm));
@@ -470,7 +470,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: writer::Encoder,
470470
encode_type_param_bounds(ebml_w, ecx, tps);
471471
let its_ty = node_id_to_type(ecx.tcx, id);
472472
debug!("fn name = %s ty = %s its node id = %d",
473-
ecx.tcx.sess.str_of(ident),
473+
*ecx.tcx.sess.str_of(ident),
474474
ty_to_str(ecx.tcx, its_ty), id);
475475
encode_type(ecx, ebml_w, its_ty);
476476
encode_path(ecx, ebml_w, path, ast_map::path_name(ident));
@@ -515,7 +515,7 @@ fn encode_info_for_method(ecx: @encode_ctxt,
515515
m: @method,
516516
+all_tps: ~[ty_param]) {
517517
debug!("encode_info_for_method: %d %s %u", m.id,
518-
ecx.tcx.sess.str_of(m.ident), all_tps.len());
518+
*ecx.tcx.sess.str_of(m.ident), all_tps.len());
519519
ebml_w.start_tag(tag_items_data_item);
520520
encode_def_id(ebml_w, local_def(m.id));
521521
match m.self_ty.node {
@@ -678,7 +678,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
678678
ebml_w,
679679
dtor.node.id,
680680
ecx.tcx.sess.ident_of(
681-
ecx.tcx.sess.str_of(item.ident) +
681+
*ecx.tcx.sess.str_of(item.ident) +
682682
~"_dtor"),
683683
path,
684684
if tps.len() > 0u {
@@ -1186,7 +1186,7 @@ fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: writer::Encoder,
11861186
dep: decoder::crate_dep) {
11871187
ebml_w.start_tag(tag_crate_dep);
11881188
ebml_w.start_tag(tag_crate_dep_name);
1189-
ebml_w.writer.write(str::to_bytes(ecx.tcx.sess.str_of(dep.name)));
1189+
ebml_w.writer.write(str::to_bytes(*ecx.tcx.sess.str_of(dep.name)));
11901190
ebml_w.end_tag();
11911191
ebml_w.start_tag(tag_crate_dep_vers);
11921192
ebml_w.writer.write(str::to_bytes(*dep.vers));

src/librustc/metadata/tyencode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn enc_bound_region(w: io::Writer, cx: @ctxt, br: ty::bound_region) {
175175
}
176176
ty::br_named(s) => {
177177
w.write_char('[');
178-
w.write_str(cx.tcx.sess.str_of(s));
178+
w.write_str(*cx.tcx.sess.str_of(s));
179179
w.write_char(']')
180180
}
181181
ty::br_cap_avoid(id, br) => {
@@ -282,7 +282,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
282282
ty::ty_rec(fields) => {
283283
w.write_str(&"R[");
284284
for fields.each |field| {
285-
w.write_str(cx.tcx.sess.str_of(field.ident));
285+
w.write_str(*cx.tcx.sess.str_of(field.ident));
286286
w.write_char('=');
287287
enc_mt(w, cx, field.mt);
288288
}

src/librustc/middle/astencode.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn encode_inlined_item(ecx: @e::encode_ctxt,
9696
maps: Maps) {
9797
debug!("> Encoding inlined item: %s::%s (%u)",
9898
ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner),
99-
ecx.tcx.sess.str_of(ii.ident()),
99+
*ecx.tcx.sess.str_of(ii.ident()),
100100
ebml_w.writer.tell());
101101

102102
let id_range = ast_util::compute_id_range_for_inlined_item(ii);
@@ -108,7 +108,7 @@ pub fn encode_inlined_item(ecx: @e::encode_ctxt,
108108

109109
debug!("< Encoded inlined fn: %s::%s (%u)",
110110
ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner),
111-
ecx.tcx.sess.str_of(ii.ident()),
111+
*ecx.tcx.sess.str_of(ii.ident()),
112112
ebml_w.writer.tell());
113113
}
114114

@@ -132,10 +132,10 @@ pub fn decode_inlined_item(cdata: cstore::crate_metadata,
132132
to_id_range: to_id_range});
133133
let raw_ii = decode_ast(ast_doc);
134134
let ii = renumber_ast(xcx, raw_ii);
135-
debug!("Fn named: %s", tcx.sess.str_of(ii.ident()));
135+
debug!("Fn named: %s", *tcx.sess.str_of(ii.ident()));
136136
debug!("< Decoded inlined fn: %s::%s",
137137
ast_map::path_to_str(path, tcx.sess.parse_sess.interner),
138-
tcx.sess.str_of(ii.ident()));
138+
*tcx.sess.str_of(ii.ident()));
139139
ast_map::map_decoded_item(tcx.sess.diagnostic(),
140140
dcx.tcx.items, path, ii);
141141
decode_side_tables(xcx, ast_doc);

src/librustc/middle/check_match.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
143143
match ty::get(ty).sty {
144144
ty::ty_bool => {
145145
match (*ctor) {
146-
val(const_bool(true)) => Some(~"true"),
147-
val(const_bool(false)) => Some(~"false"),
146+
val(const_bool(true)) => Some(@~"true"),
147+
val(const_bool(false)) => Some(@~"false"),
148148
_ => None
149149
}
150150
}
151151
ty::ty_enum(id, _) => {
152-
let vid = match (*ctor) {
152+
let vid = match *ctor {
153153
variant(id) => id,
154154
_ => fail!(~"check_exhaustive: non-variant ctor"),
155155
};
@@ -163,8 +163,8 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
163163
}
164164
}
165165
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
166-
match (*ctor) {
167-
vec(n) => Some(fmt!("vectors of length %u", n)),
166+
match *ctor {
167+
vec(n) => Some(@fmt!("vectors of length %u", n)),
168168
_ => None
169169
}
170170
}
@@ -173,7 +173,7 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
173173
}
174174
};
175175
let msg = ~"non-exhaustive patterns" + match ext {
176-
Some(ref s) => ~": " + (*s) + ~" not covered",
176+
Some(ref s) => ~": " + **s + ~" not covered",
177177
None => ~""
178178
};
179179
cx.tcx.sess.span_err(sp, msg);

src/librustc/middle/liveness.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,11 @@ impl IrMaps {
383383
}
384384
}
385385

386-
fn variable_name(&mut self, var: Variable) -> ~str {
386+
fn variable_name(&mut self, var: Variable) -> @~str {
387387
match copy self.var_kinds[*var] {
388388
Local(LocalInfo {ident: nm, _}) |
389389
Arg(_, nm, _) => self.tcx.sess.str_of(nm),
390-
ImplicitRet => ~"<implicit-ret>"
390+
ImplicitRet => @~"<implicit-ret>"
391391
}
392392
}
393393
@@ -1777,7 +1777,7 @@ impl @Liveness {
17771777
self.tcx.sess.span_err(
17781778
move_expr.span,
17791779
fmt!("illegal move from argument `%s`, which is not \
1780-
copy or move mode", self.tcx.sess.str_of(name)));
1780+
copy or move mode", *self.tcx.sess.str_of(name)));
17811781
return;
17821782
}
17831783
Local(*) | ImplicitRet => {
@@ -1798,7 +1798,7 @@ impl @Liveness {
17981798
move_expr.span,
17991799
fmt!("`%s` moved into closure environment here \
18001800
because its type is moved by default",
1801-
name));
1801+
*name));
18021802
}
18031803
expr_path(*) => {
18041804
self.report_illegal_read(
@@ -1838,7 +1838,7 @@ impl @Liveness {
18381838
move_expr.span,
18391839
fmt!("%s`%s` moved here because %s has type %s, \
18401840
which is moved by default (use `copy` to override)",
1841-
expr_descr, name, pronoun,
1841+
expr_descr, *name, pronoun,
18421842
ty_to_str(self.tcx, move_expr_ty)));
18431843
}
18441844

@@ -1858,12 +1858,12 @@ impl @Liveness {
18581858
FreeVarNode(span) => {
18591859
self.tcx.sess.span_err(
18601860
span,
1861-
fmt!("capture of %s: `%s`", msg, name));
1861+
fmt!("capture of %s: `%s`", msg, *name));
18621862
}
18631863
ExprNode(span) => {
18641864
self.tcx.sess.span_err(
18651865
span,
1866-
fmt!("use of %s: `%s`", msg, name));
1866+
fmt!("use of %s: `%s`", msg, *name));
18671867
}
18681868
ExitNode | VarDefNode(_) => {
18691869
self.tcx.sess.span_bug(
@@ -1873,9 +1873,9 @@ impl @Liveness {
18731873
}
18741874
}
18751875

1876-
fn should_warn(var: Variable) -> Option<~str> {
1876+
fn should_warn(var: Variable) -> Option<@~str> {
18771877
let name = self.ir.variable_name(var);
1878-
if name[0] == ('_' as u8) {None} else {Some(name)}
1878+
if name[0] == ('_' as u8) { None } else { Some(name) }
18791879
}
18801880

18811881
fn warn_about_unused_args(decl: fn_decl, entry_ln: LiveNode) {
@@ -1913,11 +1913,11 @@ impl @Liveness {
19131913
// FIXME(#3266)--make liveness warnings lintable
19141914
self.tcx.sess.span_warn(
19151915
sp, fmt!("variable `%s` is assigned to, \
1916-
but never used", *name));
1916+
but never used", **name));
19171917
} else {
19181918
// FIXME(#3266)--make liveness warnings lintable
19191919
self.tcx.sess.span_warn(
1920-
sp, fmt!("unused variable: `%s`", *name));
1920+
sp, fmt!("unused variable: `%s`", **name));
19211921
}
19221922
}
19231923
return true;
@@ -1931,7 +1931,7 @@ impl @Liveness {
19311931
// FIXME(#3266)--make liveness warnings lintable
19321932
self.tcx.sess.span_warn(
19331933
sp,
1934-
fmt!("value assigned to `%s` is never read", *name));
1934+
fmt!("value assigned to `%s` is never read", **name));
19351935
}
19361936
}
19371937
}

src/librustc/middle/mem_categorization.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ pub impl mem_categorization_ctxt {
629629
self.tcx.sess.span_bug(
630630
node.span(),
631631
fmt!("Cannot find field `%s` in type `%s`",
632-
self.tcx.sess.str_of(f_name),
632+
*self.tcx.sess.str_of(f_name),
633633
ty_to_str(self.tcx, base_cmt.ty)));
634634
}
635635
};
@@ -995,7 +995,7 @@ pub impl mem_categorization_ctxt {
995995
self.ptr_sigil(ptr), derefs)
996996
}
997997
cat_comp(cmt, comp) => {
998-
fmt!("%s.%s", self.cat_to_repr(cmt.cat), self.comp_to_repr(comp))
998+
fmt!("%s.%s", self.cat_to_repr(cmt.cat), *self.comp_to_repr(comp))
999999
}
10001000
cat_discr(cmt, _) => self.cat_to_repr(cmt.cat)
10011001
}
@@ -1018,13 +1018,13 @@ pub impl mem_categorization_ctxt {
10181018
}
10191019
}
10201020
1021-
fn comp_to_repr(&self, comp: comp_kind) -> ~str {
1021+
fn comp_to_repr(&self, comp: comp_kind) -> @~str {
10221022
match comp {
10231023
comp_field(fld, _) => self.tcx.sess.str_of(fld),
1024-
comp_index(*) => ~"[]",
1025-
comp_tuple => ~"()",
1026-
comp_anon_field => ~"<anonymous field>",
1027-
comp_variant(_) => ~"<enum>"
1024+
comp_index(*) => @~"[]",
1025+
comp_tuple => @~"()",
1026+
comp_anon_field => @~"<anonymous field>",
1027+
comp_variant(_) => @~"<enum>"
10281028
}
10291029
}
10301030
@@ -1043,7 +1043,7 @@ pub impl mem_categorization_ctxt {
10431043
}
10441044
lp_comp(lp, comp) => {
10451045
fmt!("%s.%s", self.lp_to_str(lp),
1046-
self.comp_to_repr(comp))
1046+
*self.comp_to_repr(comp))
10471047
}
10481048
}
10491049
}

0 commit comments

Comments
 (0)