Skip to content

Commit ace31ce

Browse files
committed
---
yaml --- r: 52301 b: refs/heads/dist-snap c: dd621bd h: refs/heads/master i: 52299: 4d34153 v: v3
1 parent 094b26e commit ace31ce

File tree

15 files changed

+109
-112
lines changed

15 files changed

+109
-112
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: a4dc65baa1caa2ef3e78b3fa8e330dda99d1e752
10+
refs/heads/dist-snap: dd621bd58d09872333926c3a761a1ee9205e6224
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/back/link.rs

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -457,32 +457,32 @@ mod write {
457457
*
458458
*/
459459

460-
fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
460+
fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
461461
symbol_hasher: &hash::State) -> link_meta {
462462

463463
type provided_metas =
464-
{name: Option<@str>,
465-
vers: Option<@str>,
464+
{name: Option<~str>,
465+
vers: Option<~str>,
466466
cmh_items: ~[@ast::meta_item]};
467467

468-
fn provided_link_metas(sess: Session, c: &ast::crate) ->
468+
fn provided_link_metas(sess: Session, c: ast::crate) ->
469469
provided_metas {
470-
let mut name = None;
471-
let mut vers = None;
472-
let mut cmh_items = ~[];
473-
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
474-
attr::require_unique_names(sess.diagnostic(), linkage_metas);
470+
let mut name: Option<~str> = None;
471+
let mut vers: Option<~str> = None;
472+
let mut cmh_items: ~[@ast::meta_item] = ~[];
473+
let linkage_metas =
474+
attr::find_linkage_metas(/*bad*/copy c.node.attrs);
475+
// XXX: Bad copy.
476+
attr::require_unique_names(sess.diagnostic(), copy linkage_metas);
475477
for linkage_metas.each |meta| {
476478
if attr::get_meta_item_name(*meta) == ~"name" {
477479
match attr::get_meta_item_value_str(*meta) {
478-
// Changing attr would avoid the need for the copy
479-
// here
480-
Some(v) => { name = Some(v.to_managed()); }
480+
Some(ref v) => { name = Some((/*bad*/copy *v)); }
481481
None => cmh_items.push(*meta)
482482
}
483483
} else if attr::get_meta_item_name(*meta) == ~"vers" {
484484
match attr::get_meta_item_value_str(*meta) {
485-
Some(v) => { vers = Some(v.to_managed()); }
485+
Some(ref v) => { vers = Some((/*bad*/copy *v)); }
486486
None => cmh_items.push(*meta)
487487
}
488488
} else { cmh_items.push(*meta); }
@@ -492,8 +492,9 @@ fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
492492

493493
// This calculates CMH as defined above
494494
fn crate_meta_extras_hash(symbol_hasher: &hash::State,
495-
-cmh_items: ~[@ast::meta_item],
496-
dep_hashes: ~[~str]) -> @str {
495+
_crate: ast::crate,
496+
metas: provided_metas,
497+
dep_hashes: ~[~str]) -> ~str {
497498
fn len_and_str(s: ~str) -> ~str {
498499
return fmt!("%u_%s", str::len(s), s);
499500
}
@@ -502,7 +503,7 @@ fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
502503
return len_and_str(pprust::lit_to_str(@l));
503504
}
504505

505-
let cmh_items = attr::sort_meta_items(cmh_items);
506+
let cmh_items = attr::sort_meta_items(/*bad*/copy metas.cmh_items);
506507

507508
symbol_hasher.reset();
508509
for cmh_items.each |m| {
@@ -525,53 +526,52 @@ fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
525526
symbol_hasher.write_str(len_and_str(*dh));
526527
}
527528

528-
// tjc: allocation is unfortunate; need to change core::hash
529-
return truncated_hash_result(symbol_hasher).to_managed();
529+
return truncated_hash_result(symbol_hasher);
530530
}
531531

532-
fn warn_missing(sess: Session, name: &str, default: &str) {
532+
fn warn_missing(sess: Session, name: ~str, default: ~str) {
533533
if !sess.building_library { return; }
534534
sess.warn(fmt!("missing crate link meta `%s`, using `%s` as default",
535535
name, default));
536536
}
537537

538-
fn crate_meta_name(sess: Session, output: &Path, -opt_name: Option<@str>)
539-
-> @str {
540-
return match opt_name {
541-
Some(v) => v,
538+
fn crate_meta_name(sess: Session, _crate: ast::crate,
539+
output: &Path, metas: provided_metas) -> ~str {
540+
return match metas.name {
541+
Some(ref v) => (/*bad*/copy *v),
542542
None => {
543-
// to_managed could go away if there was a version of
544-
// filestem that returned an @str
545-
let name = session::expect(sess,
546-
output.filestem(),
547-
|| fmt!("output file name `%s` doesn't\
543+
let name = match output.filestem() {
544+
None => sess.fatal(fmt!("output file name `%s` doesn't\
548545
appear to have a stem",
549-
output.to_str())).to_managed();
550-
warn_missing(sess, ~"name", name);
546+
output.to_str())),
547+
Some(ref s) => (/*bad*/copy *s)
548+
};
549+
// XXX: Bad copy.
550+
warn_missing(sess, ~"name", copy name);
551551
name
552552
}
553553
};
554554
}
555555

556-
fn crate_meta_vers(sess: Session, opt_vers: Option<@str>) -> @str {
557-
return match opt_vers {
558-
Some(v) => v,
556+
fn crate_meta_vers(sess: Session, _crate: ast::crate,
557+
metas: provided_metas) -> ~str {
558+
return match metas.vers {
559+
Some(ref v) => (/*bad*/copy *v),
559560
None => {
560-
let vers = @"0.0";
561-
warn_missing(sess, ~"vers", vers);
561+
let vers = ~"0.0";
562+
// Bad copy.
563+
warn_missing(sess, ~"vers", copy vers);
562564
vers
563565
}
564566
};
565567
}
566568

567-
let {name: opt_name, vers: opt_vers,
568-
cmh_items: cmh_items} = provided_link_metas(sess, c);
569-
let name = crate_meta_name(sess, output, move opt_name);
570-
let vers = crate_meta_vers(sess, move opt_vers);
569+
let provided_metas = provided_link_metas(sess, c);
570+
let name = crate_meta_name(sess, c, output, provided_metas);
571+
let vers = crate_meta_vers(sess, c, provided_metas);
571572
let dep_hashes = cstore::get_dep_hashes(sess.cstore);
572573
let extras_hash =
573-
crate_meta_extras_hash(symbol_hasher, move cmh_items,
574-
dep_hashes);
574+
crate_meta_extras_hash(symbol_hasher, c, provided_metas, dep_hashes);
575575

576576
return {name: name, vers: vers, extras_hash: extras_hash};
577577
}
@@ -583,7 +583,7 @@ fn truncated_hash_result(symbol_hasher: &hash::State) -> ~str unsafe {
583583

584584
// This calculates STH for a symbol, as defined above
585585
fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
586-
link_meta: link_meta) -> @str {
586+
link_meta: link_meta) -> ~str {
587587
// NB: do *not* use abbrevs here as we want the symbol names
588588
// to be independent of one another in the crate.
589589

@@ -593,20 +593,20 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
593593
symbol_hasher.write_str(link_meta.extras_hash);
594594
symbol_hasher.write_str(~"-");
595595
symbol_hasher.write_str(encoder::encoded_ty(tcx, t));
596-
let mut hash = truncated_hash_result(symbol_hasher);
596+
let hash = truncated_hash_result(symbol_hasher);
597597
// Prefix with _ so that it never blends into adjacent digits
598-
str::unshift_char(&mut hash, '_');
599-
// tjc: allocation is unfortunate; need to change core::hash
600-
hash.to_managed()
598+
599+
return ~"_" + hash;
601600
}
602601

603-
fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
602+
fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str {
604603
match ccx.type_hashcodes.find(t) {
605-
Some(h) => h,
604+
Some(ref h) => return (/*bad*/copy *h),
606605
None => {
607606
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
608-
ccx.type_hashcodes.insert(t, hash);
609-
hash
607+
// XXX: Bad copy. Prefer `@str`?
608+
ccx.type_hashcodes.insert(t, copy hash);
609+
return hash;
610610
}
611611
}
612612
}
@@ -664,30 +664,30 @@ fn mangle(sess: Session, ss: path) -> ~str {
664664

665665
fn exported_name(sess: Session,
666666
+path: path,
667-
hash: &str,
668-
vers: &str) -> ~str {
667+
+hash: ~str,
668+
+vers: ~str) -> ~str {
669669
return mangle(sess,
670-
vec::append_one(
671-
vec::append_one(path, path_name(sess.ident_of(hash.to_owned()))),
672-
path_name(sess.ident_of(vers.to_owned()))));
670+
vec::append_one(
671+
vec::append_one(path, path_name(sess.ident_of(hash))),
672+
path_name(sess.ident_of(vers))));
673673
}
674674

675675
fn mangle_exported_name(ccx: @crate_ctxt, +path: path, t: ty::t) -> ~str {
676676
let hash = get_symbol_hash(ccx, t);
677677
return exported_name(ccx.sess, path,
678678
hash,
679-
ccx.link_meta.vers);
679+
/*bad*/copy ccx.link_meta.vers);
680680
}
681681

682682
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
683683
t: ty::t,
684-
name: &str) -> ~str {
684+
+name: ~str) -> ~str {
685685
let s = ppaux::ty_to_short_str(ccx.tcx, t);
686686
let hash = get_symbol_hash(ccx, t);
687687
return mangle(ccx.sess,
688-
~[path_name(ccx.sess.ident_of(name.to_owned())),
689-
path_name(ccx.sess.ident_of(s)),
690-
path_name(ccx.sess.ident_of(hash.to_owned()))]);
688+
~[path_name(ccx.sess.ident_of(name)),
689+
path_name(ccx.sess.ident_of(s)),
690+
path_name(ccx.sess.ident_of(hash))]);
691691
}
692692

693693
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt,
@@ -706,7 +706,7 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, +flav: ~str) -> ~str {
706706
}
707707

708708

709-
fn output_dll_filename(os: session::os, lm: link_meta) -> ~str {
709+
fn output_dll_filename(os: session::os, lm: &link_meta) -> ~str {
710710
let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers);
711711
let (dll_prefix, dll_suffix) = match os {
712712
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
@@ -736,7 +736,7 @@ fn link_binary(sess: Session,
736736
}
737737

738738
let output = if sess.building_library {
739-
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
739+
let long_libname = output_dll_filename(sess.targ_cfg.os, &lm);
740740
debug!("link_meta.name: %s", lm.name);
741741
debug!("long_libname: %s", long_libname);
742742
debug!("out_filename: %s", out_filename.to_str());

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
108108
}
109109

110110
fn append_configuration(+cfg: ast::crate_cfg, +name: ~str) -> ast::crate_cfg {
111-
if attr::contains_name(cfg, name) {
111+
// XXX: Bad copy.
112+
if attr::contains_name(copy cfg, copy name) {
112113
return cfg;
113114
} else {
114115
return vec::append_one(cfg, attr::mk_word_item(name));

branches/dist-snap/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
297297

298298
fn is_std(cx: test_ctxt) -> bool {
299299
let is_std = {
300-
let items = attr::find_linkage_metas(cx.crate.node.attrs);
300+
let items = attr::find_linkage_metas(/*bad*/copy cx.crate.node.attrs);
301301
match attr::last_meta_item_value_str_by_name(items, ~"name") {
302302
Some(~"std") => true,
303303
_ => false

branches/dist-snap/src/librustc/metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,5 @@ const tag_lang_items_item: uint = 0x73;
152152
const tag_lang_items_item_id: uint = 0x74;
153153
const tag_lang_items_item_node_id: uint = 0x75;
154154

155-
type link_meta = {name: @str, vers: @str, extras_hash: @str};
155+
type link_meta = {name: ~str, vers: ~str, extras_hash: ~str};
156156

branches/dist-snap/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ fn visit_item(e: env, i: @ast::item) {
191191

192192
fn metas_with(+ident: ~str, +key: ~str, +metas: ~[@ast::meta_item])
193193
-> ~[@ast::meta_item] {
194-
let name_items = attr::find_meta_items_by_name(metas, key);
194+
// XXX: Bad copies.
195+
let name_items = attr::find_meta_items_by_name(copy metas, copy key);
195196
if name_items.is_empty() {
196197
vec::append_one(metas, attr::mk_name_value_item_str(key, ident))
197198
} else {

branches/dist-snap/src/librustc/metadata/encoder.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt,
881881
}
882882

883883
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder,
884-
crate: &crate) -> ~[entry<int>] {
884+
crate: @crate) -> ~[entry<int>] {
885885
let index = @mut ~[];
886886
ebml_w.start_tag(tag_items_data);
887887
index.push({val: crate_node_id, pos: ebml_w.writer.tell()});
@@ -1021,20 +1021,20 @@ fn encode_attributes(ebml_w: writer::Encoder, attrs: ~[attribute]) {
10211021
// metadata that Rust cares about for linking crates. This attribute requires
10221022
// 'name' and 'vers' items, so if the user didn't provide them we will throw
10231023
// them in anyway with default values.
1024-
fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
1024+
fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
10251025

10261026
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
10271027
attribute {
10281028

1029-
assert ecx.link_meta.name.is_not_empty();
1030-
assert ecx.link_meta.vers.is_not_empty();
1029+
assert (ecx.link_meta.name != ~"");
1030+
assert (ecx.link_meta.vers != ~"");
10311031

10321032
let name_item =
10331033
attr::mk_name_value_item_str(~"name",
1034-
ecx.link_meta.name.to_owned());
1034+
/*bad*/copy ecx.link_meta.name);
10351035
let vers_item =
10361036
attr::mk_name_value_item_str(~"vers",
1037-
ecx.link_meta.vers.to_owned());
1037+
/*bad*/copy ecx.link_meta.vers);
10381038

10391039
let other_items =
10401040
{
@@ -1156,7 +1156,7 @@ fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: writer::Encoder,
11561156
ebml_w.end_tag();
11571157
}
11581158

1159-
fn encode_hash(ebml_w: writer::Encoder, hash: &str) {
1159+
fn encode_hash(ebml_w: writer::Encoder, hash: ~str) {
11601160
ebml_w.start_tag(tag_crate_hash);
11611161
ebml_w.writer.write(str::to_bytes(hash));
11621162
ebml_w.end_tag();
@@ -1169,7 +1169,7 @@ const metadata_encoding_version : &[u8] = &[0x72, //'r' as u8,
11691169
0x74, //'t' as u8,
11701170
0, 0, 0, 1 ];
11711171

1172-
fn encode_metadata(parms: encode_parms, crate: &crate) -> ~[u8] {
1172+
fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
11731173
let wr = @io::BytesWriter();
11741174
let stats =
11751175
{mut inline_bytes: 0,
@@ -1197,7 +1197,7 @@ fn encode_metadata(parms: encode_parms, crate: &crate) -> ~[u8] {
11971197

11981198
let ebml_w = writer::Encoder(wr as io::Writer);
11991199

1200-
encode_hash(ebml_w, ecx.link_meta.extras_hash);
1200+
encode_hash(ebml_w, /*bad*/copy ecx.link_meta.extras_hash);
12011201

12021202
let mut i = wr.pos;
12031203
let crate_attrs = synthesize_crate_attrs(ecx, crate);

branches/dist-snap/src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} {
7777
}
7878

7979
fn find_library_crate(cx: ctxt) -> Option<{ident: ~str, data: @~[u8]}> {
80-
attr::require_unique_names(cx.diag, cx.metas);
80+
attr::require_unique_names(cx.diag, /*bad*/copy cx.metas);
8181
find_library_crate_aux(cx, libname(cx), cx.filesearch)
8282
}
8383

branches/dist-snap/src/librustc/middle/borrowck/preserve.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ priv impl &preserve_ctxt {
106106
let scope_region = if self.root_ub == 0 {
107107
ty::re_static
108108
} else {
109-
// Maybe if we pass in the parent instead here,
110-
// we can prevent the "scope not found" error
111-
debug!("scope_region thing: %? ", cmt.id);
112109
ty::re_scope(self.tcx().region_map.get(cmt.id))
113110
};
114111

0 commit comments

Comments
 (0)