Skip to content

Commit e17c8be

Browse files
committed
---
yaml --- r: 30463 b: refs/heads/incoming c: 2aa67e9 h: refs/heads/master i: 30461: fc8b57d 30459: 21e20aa 30455: 50b8997 30447: 51acd32 30431: bd18dca 30399: b1a2a14 30335: 145ca46 30207: a02edb7 v: v3
1 parent ec130a0 commit e17c8be

File tree

8 files changed

+48
-11
lines changed

8 files changed

+48
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: cb7a5395ddfaa7b8fc40db57b32c22f69780ccd6
9+
refs/heads/incoming: 2aa67e9aa9a29e9302337dd56313c4a2023a8900
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,13 @@ pure fn eq_slice(a: &str, b: &str) -> bool {
747747
}
748748

749749
/// Bytewise string equality
750+
#[cfg(notest)]
751+
#[lang="uniq_str_eq"]
752+
pure fn eq(a: &~str, b: &~str) -> bool {
753+
eq_slice(*a, *b)
754+
}
755+
756+
#[cfg(test)]
750757
pure fn eq(a: &~str, b: &~str) -> bool {
751758
eq_slice(*a, *b)
752759
}

branches/incoming/src/rustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
206206
middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate));
207207

208208
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
209-
region_map, rp_set);
209+
region_map, rp_set, move lang_items);
210210

211211
let (method_map, vtable_map) = time(time_passes, ~"typechecking", ||
212212
typeck::check_crate(ty_cx,

branches/incoming/src/rustc/middle/lang_items.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ struct LanguageItems {
4444
mut eq_trait: Option<def_id>,
4545
mut ord_trait: Option<def_id>,
4646

47-
mut str_eq_fn: Option<def_id>
47+
mut str_eq_fn: Option<def_id>,
48+
mut uniq_str_eq_fn: Option<def_id>
4849
}
4950

5051
mod LanguageItems {
@@ -71,7 +72,8 @@ mod LanguageItems {
7172
eq_trait: None,
7273
ord_trait: None,
7374

74-
str_eq_fn: None
75+
str_eq_fn: None,
76+
uniq_str_eq_fn: None
7577
}
7678
}
7779
}
@@ -104,6 +106,7 @@ fn LanguageItemCollector(crate: @crate, session: session,
104106
item_refs.insert(~"ord", &mut items.ord_trait);
105107

106108
item_refs.insert(~"str_eq", &mut items.str_eq_fn);
109+
item_refs.insert(~"uniq_str_eq", &mut items.uniq_str_eq_fn);
107110

108111
LanguageItemCollector {
109112
crate: crate,

branches/incoming/src/rustc/middle/trans/alt.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,27 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
436436
return rslt(rs.bcx, rs.val);
437437
}
438438

439-
// Determine the operation we need.
440-
let llop = C_u8(abi::cmp_glue_op_eq);
441-
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
442-
rslt(cx, cmpval)
439+
match ty::get(rhs_t).struct {
440+
ty::ty_estr(ty::vstore_uniq) => {
441+
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
442+
false);
443+
let scratch_lhs = alloca(cx, val_ty(lhs));
444+
Store(cx, lhs, scratch_lhs);
445+
let scratch_rhs = alloca(cx, val_ty(rhs));
446+
Store(cx, rhs, scratch_rhs);
447+
let did = cx.tcx().lang_items.uniq_str_eq_fn.get();
448+
let bcx = callee::trans_rtcall_or_lang_call(cx, did,
449+
~[scratch_lhs,
450+
scratch_rhs],
451+
expr::SaveIn(
452+
scratch_result.val));
453+
return scratch_result.to_result(bcx);
454+
}
455+
_ => {
456+
cx.tcx().sess.bug(~"only scalars and unique strings supported in \
457+
compare_values");
458+
}
459+
}
443460
}
444461

445462
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],

branches/incoming/src/rustc/middle/trans/callee.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: expr::Dest)
273273
-> block
274274
{
275275
let did = bcx.ccx().rtcalls[name];
276+
return trans_rtcall_or_lang_call(bcx, did, args, dest);
277+
}
278+
279+
fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef],
280+
dest: expr::Dest) -> block {
276281
let fty = if did.crate == ast::local_crate {
277282
ty::node_id_to_type(bcx.ccx().tcx, did.node)
278283
} else {

branches/incoming/src/rustc/middle/ty.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ type ctxt =
342342
inferred_modes: HashMap<ast::node_id, ast::mode>,
343343
// maps the id of borrowed expr to scope of borrowed ptr
344344
borrowings: HashMap<ast::node_id, borrow>,
345-
normalized_cache: HashMap<t, t>};
345+
normalized_cache: HashMap<t, t>,
346+
lang_items: middle::lang_items::LanguageItems};
346347

347348
enum tbox_flag {
348349
has_params = 1,
@@ -809,7 +810,8 @@ fn mk_ctxt(s: session::session,
809810
amap: ast_map::map,
810811
freevars: freevars::freevar_map,
811812
region_map: middle::region::region_map,
812-
region_paramd_items: middle::region::region_paramd_items) -> ctxt {
813+
region_paramd_items: middle::region::region_paramd_items,
814+
+lang_items: middle::lang_items::LanguageItems) -> ctxt {
813815
let interner = map::HashMap();
814816
let vecs_implicitly_copyable =
815817
get_lint_level(s.lint_settings.default_settings,
@@ -841,7 +843,8 @@ fn mk_ctxt(s: session::session,
841843
ty_param_bounds: map::int_hash(),
842844
inferred_modes: map::int_hash(),
843845
borrowings: map::int_hash(),
844-
normalized_cache: new_ty_hash()}
846+
normalized_cache: new_ty_hash(),
847+
lang_items: move lang_items}
845848
}
846849

847850

branches/incoming/src/test/run-pass/alt-borrowed_str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// xfail-test
2+
// xfail-fast
13
// -*- rust -*-
24
fn f1(ref_string: &str) {
35
match ref_string {

0 commit comments

Comments
 (0)