Skip to content

Commit 15ff686

Browse files
committed
---
yaml --- r: 30502 b: refs/heads/incoming c: 7eb10c4 h: refs/heads/master v: v3
1 parent 4472085 commit 15ff686

File tree

4 files changed

+26
-64
lines changed

4 files changed

+26
-64
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: 3057790f4b2b7041f187734040e856d02104ff2e
9+
refs/heads/incoming: 7eb10c4ce113f37ddd418b95629480f5d1ad9b6a
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/private.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ unsafe fn chan_from_global_ptr<T: Send>(
6363
// This is the proposed global channel
6464
let ch = comm::recv(setup_po);
6565
// 0 is our sentinal value. It is not a valid channel
66-
assert unsafe::reinterpret_cast(&ch) != 0u;
66+
assert *ch != 0;
6767
6868
// Install the channel
6969
log(debug,~"BEFORE COMPARE AND SWAP");

branches/incoming/src/libcore/unsafe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ mod tests {
400400
401401
#[test]
402402
fn test_reinterpret_cast() {
403-
assert unsafe { reinterpret_cast(&1) } == 1u;
403+
assert 1u == unsafe { reinterpret_cast(&1) };
404404
}
405405
406406
#[test]
@@ -431,7 +431,7 @@ mod tests {
431431
#[test]
432432
fn test_transmute2() {
433433
unsafe {
434-
assert transmute(~"L") == ~[76u8, 0u8];
434+
assert ~[76u8, 0u8] == transmute(~"L");
435435
}
436436
}
437437

branches/incoming/src/rustc/middle/typeck/check.rs

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
938938
call_expr_id: ast::node_id,
939939
in_fty: ty::t,
940940
callee_expr: @ast::expr,
941-
check_args: bool,
942941
args: ~[@ast::expr]) -> {fty: ty::t, bot: bool} {
943942

944943
let mut bot = false;
@@ -1028,15 +1027,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
10281027
debug!("checking the argument");
10291028
let formal_ty = formal_tys[i];
10301029
1031-
if check_args {
1032-
bot |= check_expr_with_unifier(
1033-
fcx, arg, Some(formal_ty),
1034-
|| demand::assign(fcx, arg.span, formal_ty, arg)
1035-
);
1036-
} else {
1037-
demand::assign(fcx, arg.span, formal_ty, arg);
1038-
bot |= ty::type_is_bot(fcx.expr_ty(arg));
1039-
}
1030+
bot |= check_expr_with_unifier(
1031+
fcx, arg, Some(formal_ty),
1032+
|| demand::assign(fcx, arg.span, formal_ty, arg)
1033+
);
10401034
}
10411035
}
10421036
}
@@ -1070,7 +1064,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
10701064
// Call the generic checker.
10711065
let fty = {
10721066
let r = check_call_inner(fcx, sp, call_expr_id,
1073-
fn_ty, f, true, args);
1067+
fn_ty, f, args);
10741068
bot |= r.bot;
10751069
r.fty
10761070
};
@@ -1126,8 +1120,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11261120
11271121
fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr,
11281122
self_ex: @ast::expr, self_t: ty::t,
1129-
opname: ast::ident, check_args: bool,
1130-
args: ~[@ast::expr])
1123+
opname: ast::ident, args: ~[@ast::expr])
11311124
-> Option<(ty::t, bool)>
11321125
{
11331126
match method::lookup(fcx, op_ex, self_ex,
@@ -1136,7 +1129,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11361129
let {fty: method_ty, bot: bot} = {
11371130
let method_ty = fcx.node_ty(op_ex.callee_id);
11381131
check_call_inner(fcx, op_ex.span, op_ex.id,
1139-
method_ty, op_ex, check_args, args)
1132+
method_ty, op_ex, args)
11401133
};
11411134
fcx.ccx.method_map.insert(op_ex.id, origin);
11421135
Some((ty::ty_fn_ret(method_ty), bot))
@@ -1145,52 +1138,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11451138
}
11461139
}
11471140
1148-
fn check_rel_op(fcx: @fn_ctxt,
1149-
expr: @ast::expr,
1150-
op: ast::binop,
1151-
lhs: @ast::expr,
1152-
rhs: @ast::expr) -> bool
1153-
{
1154-
// We know that only things of equal type can be compared, so
1155-
// go ahead and unify the two types before we do anything else
1156-
// (with other operators, we must be much more careful not to
1157-
// make assumptions, due to the possibility of operator
1158-
// overloading; but overloaded == still enforces the
1159-
// requirement that only equal types are compared).
1160-
let tcx = fcx.ccx.tcx;
1161-
let lhs_bot = check_expr(fcx, lhs, None);
1162-
let lhs_t = fcx.expr_ty(lhs);
1163-
let rhs_bot = check_expr_with(fcx, rhs, lhs_t);
1164-
1165-
let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t);
1166-
if ty::is_binopable(tcx, lhs_t, op) {
1167-
let result_t = ty::mk_bool(tcx);
1168-
fcx.write_ty(expr.id, result_t);
1169-
return lhs_bot | rhs_bot;
1170-
}
1171-
1172-
let (result, rhs_bot) =
1173-
check_user_binop(fcx, expr, lhs, lhs_t, op, false, rhs);
1174-
fcx.write_ty(expr.id, result);
1175-
return lhs_bot | rhs_bot;
1176-
}
1177-
11781141
// could be either a expr_binop or an expr_assign_binop
11791142
fn check_binop(fcx: @fn_ctxt, expr: @ast::expr,
11801143
op: ast::binop,
11811144
lhs: @ast::expr,
11821145
rhs: @ast::expr) -> bool {
11831146
let tcx = fcx.ccx.tcx;
11841147
1185-
// Relational operators are different for type inferencing
1186-
// reasons.
1187-
match op {
1188-
ast::eq | ast::ne | ast::lt | ast::le | ast::ge | ast::gt => {
1189-
return check_rel_op(fcx, expr, op, lhs, rhs);
1190-
}
1191-
_ => {}
1192-
}
1193-
11941148
let lhs_bot = check_expr(fcx, lhs, None);
11951149
let lhs_t = fcx.expr_ty(lhs);
11961150
let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t);
@@ -1208,7 +1162,16 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
12081162
let tvar = fcx.infcx().next_ty_var();
12091163
demand::suptype(fcx, expr.span, tvar, lhs_t);
12101164
let rhs_bot = check_expr_with(fcx, rhs, tvar);
1211-
let result_t = lhs_t;
1165+
1166+
let result_t = match op {
1167+
ast::eq | ast::ne | ast::lt | ast::le | ast::ge | ast::gt => {
1168+
ty::mk_bool(tcx)
1169+
}
1170+
_ => {
1171+
lhs_t
1172+
}
1173+
};
1174+
12121175
fcx.write_ty(expr.id, result_t);
12131176
return {
12141177
if !ast_util::lazy_binop(op) { lhs_bot | rhs_bot }
@@ -1217,22 +1180,21 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
12171180
}
12181181
12191182
let (result, rhs_bot) =
1220-
check_user_binop(fcx, expr, lhs, lhs_t, op, true, rhs);
1183+
check_user_binop(fcx, expr, lhs, lhs_t, op, rhs);
12211184
fcx.write_ty(expr.id, result);
12221185
return lhs_bot | rhs_bot;
12231186
}
12241187
12251188
fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr,
12261189
lhs_expr: @ast::expr, lhs_resolved_t: ty::t,
1227-
op: ast::binop, check_rhs: bool,
1228-
rhs: @ast::expr) -> (ty::t, bool)
1190+
op: ast::binop, rhs: @ast::expr) -> (ty::t, bool)
12291191
{
12301192
let tcx = fcx.ccx.tcx;
12311193
match ast_util::binop_to_method_name(op) {
12321194
Some(name) => {
12331195
match lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t,
12341196
fcx.tcx().sess.ident_of(name),
1235-
check_rhs, ~[rhs]) {
1197+
~[rhs]) {
12361198
Some(pair) => return pair,
12371199
_ => ()
12381200
}
@@ -1266,7 +1228,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
12661228
ex: @ast::expr,
12671229
rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t {
12681230
match lookup_op_method(fcx, ex, rhs_expr, rhs_t,
1269-
fcx.tcx().sess.ident_of(mname), true, ~[]) {
1231+
fcx.tcx().sess.ident_of(mname), ~[]) {
12701232
Some((ret_ty, _)) => ret_ty,
12711233
_ => {
12721234
fcx.ccx.tcx.sess.span_err(
@@ -2073,7 +2035,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
20732035
let resolved = structurally_resolved_type(fcx, expr.span,
20742036
raw_base_t);
20752037
match lookup_op_method(fcx, expr, base, resolved,
2076-
tcx.sess.ident_of(~"index"), true,
2038+
tcx.sess.ident_of(~"index"),
20772039
~[idx]) {
20782040
Some((ret_ty, _)) => fcx.write_ty(id, ret_ty),
20792041
_ => {

0 commit comments

Comments
 (0)