mirror of https://github.com/rust-lang/rust.git
auto merge of #13915 : nick29581/rust/rslt, r=luqmana
This commit is contained in:
commit
1c9b77643c
|
@ -340,16 +340,16 @@ 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);
|
||||
|
@ -357,13 +357,13 @@ fn trans_opt<'a>(bcx: &'a Block<'a>, o: &Opt) -> opt_result<'a> {
|
|||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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, ..},
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>(
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
|
|
@ -746,7 +746,7 @@ pub fn trans_call_inner<'a>(
|
|||
Unreachable(bcx);
|
||||
}
|
||||
|
||||
rslt(bcx, llresult)
|
||||
Result::new(bcx, llresult)
|
||||
}
|
||||
|
||||
pub enum CallArgs<'a> {
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue