Skip to content

Commit

Permalink
auto merge of #13915 : nick29581/rust/rslt, r=luqmana
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed May 4, 2014
2 parents 9c1761d + 5854811 commit 1c9b776
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
22 changes: 11 additions & 11 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,30 +340,30 @@ fn trans_opt<'a>(bcx: &'a Block<'a>, o: &Opt) -> opt_result<'a> {
let lit_datum = unpack_datum!(bcx, expr::trans(bcx, lit_expr));
let lit_datum = lit_datum.assert_rvalue(bcx); // literals are rvalues
let lit_datum = unpack_datum!(bcx, lit_datum.to_appropriate_datum(bcx));
return single_result(rslt(bcx, lit_datum.val));
return single_result(Result::new(bcx, lit_datum.val));
}
lit(UnitLikeStructLit(pat_id)) => {
let struct_ty = ty::node_id_to_type(bcx.tcx(), pat_id);
let datum = datum::rvalue_scratch_datum(bcx, struct_ty, "");
return single_result(rslt(bcx, datum.val));
return single_result(Result::new(bcx, datum.val));
}
lit(ConstLit(lit_id)) => {
let (llval, _) = consts::get_const_val(bcx.ccx(), lit_id);
return single_result(rslt(bcx, llval));
return single_result(Result::new(bcx, llval));
}
var(disr_val, ref repr) => {
return adt::trans_case(bcx, &**repr, disr_val);
}
range(l1, l2) => {
let (l1, _) = consts::const_expr(ccx, l1, true);
let (l2, _) = consts::const_expr(ccx, l2, true);
return range_result(rslt(bcx, l1), rslt(bcx, l2));
return range_result(Result::new(bcx, l1), Result::new(bcx, l2));
}
vec_len(n, vec_len_eq, _) => {
return single_result(rslt(bcx, C_int(ccx, n as int)));
return single_result(Result::new(bcx, C_int(ccx, n as int)));
}
vec_len(n, vec_len_ge(_), _) => {
return lower_bound(rslt(bcx, C_int(ccx, n as int)));
return lower_bound(Result::new(bcx, C_int(ccx, n as int)));
}
}
}
Expand Down Expand Up @@ -1311,7 +1311,7 @@ fn compare_values<'a>(
let _icx = push_ctxt("compare_values");
if ty::type_is_scalar(rhs_t) {
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq);
return rslt(rs.bcx, rs.val);
return Result::new(rs.bcx, rs.val);
}

match ty::get(rhs_t).sty {
Expand Down Expand Up @@ -1742,7 +1742,7 @@ fn compile_submatch_continue<'a, 'b>(
compare_scalar_types(
bcx, test_val, vend,
t, ast::BiLe);
rslt(bcx, And(bcx, llge, llle))
Result::new(bcx, And(bcx, llge, llle))
}
}
};
Expand All @@ -1757,14 +1757,14 @@ fn compile_submatch_continue<'a, 'b>(
let value = compare_scalar_values(
bcx, test_val, val,
signed_int, ast::BiEq);
rslt(bcx, value)
Result::new(bcx, value)
}
lower_bound(
Result {bcx, val: val}) => {
let value = compare_scalar_values(
bcx, test_val, val,
signed_int, ast::BiGe);
rslt(bcx, value)
Result::new(bcx, value)
}
range_result(
Result {val: vbegin, ..},
Expand All @@ -1777,7 +1777,7 @@ fn compile_submatch_continue<'a, 'b>(
compare_scalar_values(
bcx, test_val, vend,
signed_int, ast::BiLe);
rslt(bcx, And(bcx, llge, llle))
Result::new(bcx, And(bcx, llge, llle))
}
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,19 +579,19 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr)
-> _match::opt_result<'a> {
match *r {
CEnum(ity, _, _) => {
_match::single_result(rslt(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
discr as u64, true)))
_match::single_result(Result::new(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
discr as u64, true)))
}
General(ity, _) => {
_match::single_result(rslt(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
discr as u64, true)))
_match::single_result(Result::new(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
discr as u64, true)))
}
Univariant(..) => {
bcx.ccx().sess().bug("no cases for univariants or structs")
}
NullablePointer{ .. } => {
assert!(discr == 0 || discr == 1);
_match::single_result(rslt(bcx, C_i1(bcx.ccx(), discr != 0)))
_match::single_result(Result::new(bcx, C_i1(bcx.ccx(), discr != 0)))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub fn malloc_raw_dyn<'a>(bcx: &'a Block<'a>,
None);

let llty_ptr = type_of::type_of(ccx, ptr_ty);
rslt(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
}

pub fn malloc_raw_dyn_managed<'a>(
Expand Down Expand Up @@ -393,7 +393,7 @@ pub fn malloc_raw_dyn_managed<'a>(
llalign
],
None);
rslt(r.bcx, PointerCast(r.bcx, r.val, llty))
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty))
}

// Type descriptor and type glue stuff
Expand Down Expand Up @@ -543,7 +543,7 @@ pub fn compare_scalar_types<'a>(
t: ty::t,
op: ast::BinOp)
-> Result<'a> {
let f = |a| rslt(cx, compare_scalar_values(cx, lhs, rhs, a, op));
let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));

match ty::get(t).sty {
ty::ty_nil => f(nil_type),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ pub fn trans_call_inner<'a>(
Unreachable(bcx);
}

rslt(bcx, llresult)
Result::new(bcx, llresult)
}

pub enum CallArgs<'a> {
Expand Down Expand Up @@ -904,5 +904,5 @@ pub fn trans_arg_datum<'a>(
}

debug!("--- trans_arg_datum passing {}", bcx.val_to_str(val));
rslt(bcx, val)
Result::new(bcx, val)
}
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn allocate_cbox<'a>(bcx: &'a Block<'a>,
ty::RegionTraitStore(..) => {
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
rslt(bcx, llbox)
Result::new(bcx, llbox)
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,12 @@ pub struct Result<'a> {
pub val: ValueRef
}

pub fn rslt<'a>(bcx: &'a Block<'a>, val: ValueRef) -> Result<'a> {
Result {
bcx: bcx,
val: val,
impl<'a> Result<'a> {
pub fn new(bcx: &'a Block<'a>, val: ValueRef) -> Result<'a> {
Result {
bcx: bcx,
val: val,
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,6 @@ impl<'a> DatumBlock<'a, Expr> {

pub fn to_llbool(self) -> Result<'a> {
let DatumBlock { datum, bcx } = self;
rslt(bcx, datum.to_llbool(bcx))
Result::new(bcx, datum.to_llbool(bcx))
}
}

0 comments on commit 1c9b776

Please sign in to comment.