Autoderef in librustc_trans
This commit is contained in:
parent
f831d98ba2
commit
93e58cc28f
27 changed files with 263 additions and 264 deletions
|
|
@ -916,7 +916,7 @@ fn link_natively(sess: &Session, dylib: bool,
|
|||
pname,
|
||||
prog.status))
|
||||
.note(&format!("{:?}", &cmd))
|
||||
.note(&*escape_string(&output[..]))
|
||||
.note(&escape_string(&output[..]))
|
||||
.emit();
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
|
|||
match llvm::diagnostic::Diagnostic::unpack(info) {
|
||||
llvm::diagnostic::InlineAsm(inline) => {
|
||||
report_inline_asm(cgcx,
|
||||
&*llvm::twine_to_string(inline.message),
|
||||
&llvm::twine_to_string(inline.message),
|
||||
inline.cookie);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
&name.as_str(),
|
||||
&qualname,
|
||||
&self.span.snippet(expr.span),
|
||||
&ty_to_string(&*typ),
|
||||
&ty_to_string(&typ),
|
||||
self.cur_scope);
|
||||
|
||||
// walk type and init value
|
||||
|
|
@ -550,7 +550,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
|
||||
for field in variant.node.data.fields() {
|
||||
self.process_struct_field_def(field, variant.node.data.id());
|
||||
self.visit_ty(&*field.node.ty);
|
||||
self.visit_ty(&field.node.ty);
|
||||
}
|
||||
}
|
||||
self.process_generic_params(ty_params, item.span, &enum_data.qualname, enum_data.id);
|
||||
|
|
@ -970,7 +970,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
self.cur_scope);
|
||||
}
|
||||
Fn(ref decl, _, _, _, ref ty_params, ref body) =>
|
||||
self.process_fn(item, &**decl, ty_params, &**body),
|
||||
self.process_fn(item, &decl, ty_params, &body),
|
||||
Static(ref typ, _, ref expr) =>
|
||||
self.process_static_or_const_item(item, typ, expr),
|
||||
Const(ref typ, ref expr) =>
|
||||
|
|
@ -992,11 +992,11 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
}
|
||||
Ty(ref ty, ref ty_params) => {
|
||||
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
|
||||
let value = ty_to_string(&**ty);
|
||||
let value = ty_to_string(&ty);
|
||||
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type);
|
||||
self.fmt.typedef_str(item.span, sub_span, item.id, &qualname, &value);
|
||||
|
||||
self.visit_ty(&**ty);
|
||||
self.visit_ty(&ty);
|
||||
self.process_generic_params(ty_params, item.span, &qualname, item.id);
|
||||
}
|
||||
Mac(_) => (),
|
||||
|
|
@ -1012,7 +1012,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
if let Some(ref ty) = param.default {
|
||||
self.visit_ty(&**ty);
|
||||
self.visit_ty(&ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1024,8 +1024,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
self.process_const(trait_item.id,
|
||||
trait_item.ident.name,
|
||||
trait_item.span,
|
||||
&*ty,
|
||||
&*expr);
|
||||
&ty,
|
||||
&expr);
|
||||
}
|
||||
ast::TraitItemKind::Method(ref sig, ref body) => {
|
||||
self.process_method(sig,
|
||||
|
|
@ -1113,7 +1113,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
ast::ExprKind::TupField(ref sub_ex, idx) => {
|
||||
self.visit_expr(&**sub_ex);
|
||||
self.visit_expr(&sub_ex);
|
||||
|
||||
let hir_node = lower_expr(self.save_ctxt.lcx, sub_ex);
|
||||
let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty;
|
||||
|
|
@ -1139,15 +1139,15 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
|
||||
// walk arg and return types
|
||||
for arg in &decl.inputs {
|
||||
self.visit_ty(&*arg.ty);
|
||||
self.visit_ty(&arg.ty);
|
||||
}
|
||||
|
||||
if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output {
|
||||
self.visit_ty(&**ret_ty);
|
||||
self.visit_ty(&ret_ty);
|
||||
}
|
||||
|
||||
// walk the body
|
||||
self.nest(ex.id, |v| v.visit_block(&**body));
|
||||
self.nest(ex.id, |v| v.visit_block(&body));
|
||||
}
|
||||
ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) |
|
||||
ast::ExprKind::WhileLet(ref pattern, ref subexpression, ref block, _) => {
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
match item.node {
|
||||
hir::ItemImpl(_, _, _, _, ref ty, _) => {
|
||||
let mut result = String::from("<");
|
||||
result.push_str(&rustc_front::print::pprust::ty_to_string(&**ty));
|
||||
result.push_str(&rustc_front::print::pprust::ty_to_string(&ty));
|
||||
|
||||
match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
|
||||
Some(def_id) => {
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> {
|
|||
match *self {
|
||||
ConstantValue(ConstantExpr(lit_expr), _) => {
|
||||
let lit_ty = bcx.tcx().node_id_to_type(lit_expr.id);
|
||||
let expr = consts::const_expr(ccx, &*lit_expr, bcx.fcx.param_substs, None, Yes);
|
||||
let expr = consts::const_expr(ccx, &lit_expr, bcx.fcx.param_substs, None, Yes);
|
||||
let llval = match expr {
|
||||
Ok((llval, _)) => llval,
|
||||
Err(err) => bcx.ccx().sess().span_fatal(lit_expr.span, &err.description()),
|
||||
|
|
@ -294,18 +294,18 @@ impl<'a, 'tcx> Opt<'a, 'tcx> {
|
|||
SingleResult(Result::new(bcx, lit_datum.val))
|
||||
}
|
||||
ConstantRange(ConstantExpr(ref l1), ConstantExpr(ref l2), _) => {
|
||||
let l1 = match consts::const_expr(ccx, &**l1, bcx.fcx.param_substs, None, Yes) {
|
||||
let l1 = match consts::const_expr(ccx, &l1, bcx.fcx.param_substs, None, Yes) {
|
||||
Ok((l1, _)) => l1,
|
||||
Err(err) => bcx.ccx().sess().span_fatal(l1.span, &err.description()),
|
||||
};
|
||||
let l2 = match consts::const_expr(ccx, &**l2, bcx.fcx.param_substs, None, Yes) {
|
||||
let l2 = match consts::const_expr(ccx, &l2, bcx.fcx.param_substs, None, Yes) {
|
||||
Ok((l2, _)) => l2,
|
||||
Err(err) => bcx.ccx().sess().span_fatal(l2.span, &err.description()),
|
||||
};
|
||||
RangeResult(Result::new(bcx, l1), Result::new(bcx, l2))
|
||||
}
|
||||
Variant(disr_val, ref repr, _, _) => {
|
||||
SingleResult(Result::new(bcx, adt::trans_case(bcx, &**repr, disr_val)))
|
||||
SingleResult(Result::new(bcx, adt::trans_case(bcx, &repr, disr_val)))
|
||||
}
|
||||
SliceLengthEqual(length, _) => {
|
||||
SingleResult(Result::new(bcx, C_uint(ccx, length)))
|
||||
|
|
@ -479,7 +479,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
pat = match pat.node {
|
||||
hir::PatIdent(_, ref path, Some(ref inner)) => {
|
||||
bound_ptrs.push((path.node.name, val.val));
|
||||
&**inner
|
||||
&inner
|
||||
},
|
||||
_ => break
|
||||
}
|
||||
|
|
@ -489,7 +489,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
pats[col] = pat;
|
||||
Match {
|
||||
pats: pats,
|
||||
data: &*br.data,
|
||||
data: &br.data,
|
||||
bound_ptrs: bound_ptrs,
|
||||
pat_renaming_map: br.pat_renaming_map,
|
||||
}
|
||||
|
|
@ -518,7 +518,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
let mut bound_ptrs = br.bound_ptrs.clone();
|
||||
match this.node {
|
||||
hir::PatIdent(_, ref path, None) => {
|
||||
if pat_is_binding(&dm.borrow(), &*this) {
|
||||
if pat_is_binding(&dm.borrow(), &this) {
|
||||
bound_ptrs.push((path.node.name, val.val));
|
||||
}
|
||||
}
|
||||
|
|
@ -557,7 +557,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
// Collect all of the matches that can match against anything.
|
||||
enter_match(bcx, dm, m, col, val, |pats| {
|
||||
if pat_is_binding_or_wild(&dm.borrow(), &*pats[col]) {
|
||||
if pat_is_binding_or_wild(&dm.borrow(), &pats[col]) {
|
||||
let mut r = pats[..col].to_vec();
|
||||
r.extend_from_slice(&pats[col + 1..]);
|
||||
Some(r)
|
||||
|
|
@ -615,11 +615,11 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
|
|||
|
||||
let ctor = match opt {
|
||||
&ConstantValue(ConstantExpr(expr), _) => check_match::ConstantValue(
|
||||
const_eval::eval_const_expr(bcx.tcx(), &*expr)
|
||||
const_eval::eval_const_expr(bcx.tcx(), &expr)
|
||||
),
|
||||
&ConstantRange(ConstantExpr(lo), ConstantExpr(hi), _) => check_match::ConstantRange(
|
||||
const_eval::eval_const_expr(bcx.tcx(), &*lo),
|
||||
const_eval::eval_const_expr(bcx.tcx(), &*hi)
|
||||
const_eval::eval_const_expr(bcx.tcx(), &lo),
|
||||
const_eval::eval_const_expr(bcx.tcx(), &hi)
|
||||
),
|
||||
&SliceLengthEqual(n, _) =>
|
||||
check_match::Slice(n),
|
||||
|
|
@ -663,7 +663,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let opt = match cur.node {
|
||||
hir::PatLit(ref l) => {
|
||||
ConstantValue(ConstantExpr(&**l), debug_loc)
|
||||
ConstantValue(ConstantExpr(&l), debug_loc)
|
||||
}
|
||||
hir::PatIdent(..) | hir::PatEnum(..) | hir::PatStruct(..) => {
|
||||
// This is either an enum variant or a variable binding.
|
||||
|
|
@ -680,7 +680,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
hir::PatRange(ref l1, ref l2) => {
|
||||
ConstantRange(ConstantExpr(&**l1), ConstantExpr(&**l2), debug_loc)
|
||||
ConstantRange(ConstantExpr(&l1), ConstantExpr(&l2), debug_loc)
|
||||
}
|
||||
hir::PatVec(ref before, None, ref after) => {
|
||||
SliceLengthEqual(before.len() + after.len(), debug_loc)
|
||||
|
|
@ -849,7 +849,7 @@ impl FailureHandler {
|
|||
fn pick_column_to_specialize(def_map: &RefCell<DefMap>, m: &[Match]) -> Option<usize> {
|
||||
fn pat_score(def_map: &RefCell<DefMap>, pat: &hir::Pat) -> usize {
|
||||
match pat.node {
|
||||
hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner),
|
||||
hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &inner),
|
||||
_ if pat_is_refutable(&def_map.borrow(), pat) => 1,
|
||||
_ => 0
|
||||
}
|
||||
|
|
@ -1143,7 +1143,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
match data.arm.guard {
|
||||
Some(ref guard_expr) => {
|
||||
bcx = compile_guard(bcx,
|
||||
&**guard_expr,
|
||||
&guard_expr,
|
||||
m[0].data,
|
||||
&m[1..m.len()],
|
||||
vals,
|
||||
|
|
@ -1190,7 +1190,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) {
|
||||
let repr = adt::represent_type(bcx.ccx(), left_ty);
|
||||
let arg_count = adt::num_args(&*repr, Disr(0));
|
||||
let arg_count = adt::num_args(&repr, Disr(0));
|
||||
let (arg_count, struct_val) = if type_is_sized(bcx.tcx(), left_ty) {
|
||||
(arg_count, val.val)
|
||||
} else {
|
||||
|
|
@ -1202,7 +1202,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
let mut field_vals: Vec<ValueRef> = (0..arg_count).map(|ix|
|
||||
// By definition, these are all sized
|
||||
adt::trans_field_ptr(bcx, &*repr, adt::MaybeSizedValue::sized(struct_val), Disr(0), ix)
|
||||
adt::trans_field_ptr(bcx, &repr, adt::MaybeSizedValue::sized(struct_val), Disr(0), ix)
|
||||
).collect();
|
||||
|
||||
match left_ty.sty {
|
||||
|
|
@ -1218,7 +1218,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
let meta = Load(bcx, expr::get_meta(bcx, val.val));
|
||||
let struct_val = adt::MaybeSizedValue::unsized_(struct_val, meta);
|
||||
|
||||
let data = adt::trans_field_ptr(bcx, &*repr, struct_val, Disr(0), arg_count);
|
||||
let data = adt::trans_field_ptr(bcx, &repr, struct_val, Disr(0), arg_count);
|
||||
Store(bcx, data, expr::get_dataptr(bcx, scratch));
|
||||
Store(bcx, meta, expr::get_meta(bcx, scratch));
|
||||
field_vals.push(scratch);
|
||||
|
|
@ -1385,7 +1385,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
match *opt {
|
||||
Variant(disr_val, ref repr, _, _) => {
|
||||
let ExtractedBlock {vals: argvals, bcx: new_bcx} =
|
||||
extract_variant_args(opt_cx, &**repr, disr_val, val);
|
||||
extract_variant_args(opt_cx, &repr, disr_val, val);
|
||||
size = argvals.len();
|
||||
unpacked = argvals;
|
||||
opt_cx = new_bcx;
|
||||
|
|
@ -1534,7 +1534,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &hir::Pat,
|
|||
let tcx = bcx.tcx();
|
||||
let reassigned = is_discr_reassigned(bcx, discr, body);
|
||||
let mut bindings_map = FnvHashMap();
|
||||
pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| {
|
||||
pat_bindings(&tcx.def_map, &pat, |bm, p_id, span, path1| {
|
||||
let name = path1.node;
|
||||
let variable_ty = node_id_type(bcx, p_id);
|
||||
let llvariable_ty = type_of::type_of(ccx, variable_ty);
|
||||
|
|
@ -1604,7 +1604,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
let arm_datas: Vec<ArmData> = arms.iter().map(|arm| ArmData {
|
||||
bodycx: fcx.new_id_block("case_body", arm.body.id),
|
||||
arm: arm,
|
||||
bindings_map: create_bindings_map(bcx, &*arm.pats[0], discr_expr, &*arm.body)
|
||||
bindings_map: create_bindings_map(bcx, &arm.pats[0], discr_expr, &arm.body)
|
||||
}).collect();
|
||||
|
||||
let mut pat_renaming_map = if scope_cx.sess().opts.debuginfo != NoDebugInfo {
|
||||
|
|
@ -1624,7 +1624,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
let mut matches = Vec::new();
|
||||
for (arm_data, pats) in arm_datas.iter().zip(&arm_pats) {
|
||||
matches.extend(pats.iter().map(|p| Match {
|
||||
pats: vec![&**p],
|
||||
pats: vec![&p],
|
||||
data: arm_data,
|
||||
bound_ptrs: Vec::new(),
|
||||
pat_renaming_map: pat_renaming_map.as_ref()
|
||||
|
|
@ -1651,7 +1651,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
// insert bindings into the lllocals map and add cleanups
|
||||
let cs = fcx.push_custom_cleanup_scope();
|
||||
bcx = insert_lllocals(bcx, &arm_data.bindings_map, Some(cleanup::CustomScope(cs)));
|
||||
bcx = expr::trans_into(bcx, &*arm_data.arm.body, dest);
|
||||
bcx = expr::trans_into(bcx, &arm_data.arm.body, dest);
|
||||
bcx = fcx.pop_and_trans_custom_cleanup_scope(bcx, cs);
|
||||
arm_cxs.push(bcx);
|
||||
}
|
||||
|
|
@ -1668,7 +1668,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let _icx = push_ctxt("match::store_local");
|
||||
let mut bcx = bcx;
|
||||
let tcx = bcx.tcx();
|
||||
let pat = &*local.pat;
|
||||
let pat = &local.pat;
|
||||
|
||||
fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
pat: &hir::Pat)
|
||||
|
|
@ -1723,7 +1723,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
return mk_binding_alloca(
|
||||
bcx, pat.id, name, var_scope, (),
|
||||
"_match::store_local",
|
||||
|(), bcx, Datum { val: v, .. }| expr::trans_into(bcx, &**init_expr,
|
||||
|(), bcx, Datum { val: v, .. }| expr::trans_into(bcx, &init_expr,
|
||||
expr::SaveIn(v)));
|
||||
}
|
||||
|
||||
|
|
@ -1732,7 +1732,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
// General path.
|
||||
let init_datum =
|
||||
unpack_datum!(bcx, expr::trans_to_lvalue(bcx, &**init_expr, "let"));
|
||||
unpack_datum!(bcx, expr::trans_to_lvalue(bcx, &init_expr, "let"));
|
||||
if bcx.sess().asm_comments() {
|
||||
add_comment(bcx, "creating zeroable ref llval");
|
||||
}
|
||||
|
|
@ -1813,7 +1813,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let ccx = bcx.ccx();
|
||||
match pat.node {
|
||||
hir::PatIdent(pat_binding_mode, ref path1, ref inner) => {
|
||||
if pat_is_binding(&tcx.def_map.borrow(), &*pat) {
|
||||
if pat_is_binding(&tcx.def_map.borrow(), &pat) {
|
||||
// Allocate the stack slot where the value of this
|
||||
// binding will live and place it into the appropriate
|
||||
// map.
|
||||
|
|
@ -1846,7 +1846,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
if let Some(ref inner_pat) = *inner {
|
||||
bcx = bind_irrefutable_pat(bcx, &**inner_pat, val, cleanup_scope);
|
||||
bcx = bind_irrefutable_pat(bcx, &inner_pat, val, cleanup_scope);
|
||||
}
|
||||
}
|
||||
hir::PatEnum(_, ref sub_pats) => {
|
||||
|
|
@ -1856,14 +1856,14 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let repr = adt::represent_node(bcx, pat.id);
|
||||
let vinfo = ccx.tcx().lookup_adt_def(enum_id).variant_with_id(var_id);
|
||||
let args = extract_variant_args(bcx,
|
||||
&*repr,
|
||||
&repr,
|
||||
Disr::from(vinfo.disr_val),
|
||||
val);
|
||||
if let Some(ref sub_pat) = *sub_pats {
|
||||
for (i, &argval) in args.vals.iter().enumerate() {
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx,
|
||||
&*sub_pat[i],
|
||||
&sub_pat[i],
|
||||
MatchInput::from_val(argval),
|
||||
cleanup_scope);
|
||||
}
|
||||
|
|
@ -1879,11 +1879,11 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let repr = adt::represent_node(bcx, pat.id);
|
||||
let val = adt::MaybeSizedValue::sized(val.val);
|
||||
for (i, elem) in elems.iter().enumerate() {
|
||||
let fldptr = adt::trans_field_ptr(bcx, &*repr,
|
||||
let fldptr = adt::trans_field_ptr(bcx, &repr,
|
||||
val, Disr(0), i);
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx,
|
||||
&**elem,
|
||||
&elem,
|
||||
MatchInput::from_val(fldptr),
|
||||
cleanup_scope);
|
||||
}
|
||||
|
|
@ -1914,7 +1914,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let field_idx = pat_v.field_index(name);
|
||||
let mut fldptr = adt::trans_field_ptr(
|
||||
bcx,
|
||||
&*pat_repr,
|
||||
&pat_repr,
|
||||
val,
|
||||
pat_v.discr,
|
||||
field_idx);
|
||||
|
|
@ -1930,7 +1930,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fldptr = scratch;
|
||||
}
|
||||
bcx = bind_irrefutable_pat(bcx,
|
||||
&*f.node.pat,
|
||||
&f.node.pat,
|
||||
MatchInput::from_val(fldptr),
|
||||
cleanup_scope);
|
||||
}
|
||||
|
|
@ -1939,10 +1939,10 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let repr = adt::represent_node(bcx, pat.id);
|
||||
let val = adt::MaybeSizedValue::sized(val.val);
|
||||
for (i, elem) in elems.iter().enumerate() {
|
||||
let fldptr = adt::trans_field_ptr(bcx, &*repr, val, Disr(0), i);
|
||||
let fldptr = adt::trans_field_ptr(bcx, &repr, val, Disr(0), i);
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx,
|
||||
&**elem,
|
||||
&elem,
|
||||
MatchInput::from_val(fldptr),
|
||||
cleanup_scope);
|
||||
}
|
||||
|
|
@ -1964,7 +1964,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
val.val
|
||||
};
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx, &**inner, MatchInput::from_val(val), cleanup_scope);
|
||||
bcx, &inner, MatchInput::from_val(val), cleanup_scope);
|
||||
}
|
||||
hir::PatRegion(ref inner, _) => {
|
||||
let pat_ty = node_id_type(bcx, inner.id);
|
||||
|
|
@ -1984,7 +1984,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx,
|
||||
&**inner,
|
||||
&inner,
|
||||
MatchInput::from_val(val),
|
||||
cleanup_scope);
|
||||
}
|
||||
|
|
@ -2008,7 +2008,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
.fold(bcx, |bcx, (inner, elem)| {
|
||||
bind_irrefutable_pat(
|
||||
bcx,
|
||||
&**inner,
|
||||
&inner,
|
||||
MatchInput::from_val(elem),
|
||||
cleanup_scope)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
|||
for (i, out) in ia.outputs.iter().enumerate() {
|
||||
constraints.push(out.constraint.clone());
|
||||
|
||||
let out_datum = unpack_datum!(bcx, expr::trans(bcx, &*out.expr));
|
||||
let out_datum = unpack_datum!(bcx, expr::trans(bcx, &out.expr));
|
||||
if out.is_indirect {
|
||||
bcx = callee::trans_arg_datum(bcx,
|
||||
expr_ty(bcx, &*out.expr),
|
||||
expr_ty(bcx, &out.expr),
|
||||
out_datum,
|
||||
cleanup::CustomScope(temp_scope),
|
||||
callee::DontAutorefArg,
|
||||
|
|
@ -61,7 +61,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
|||
outputs.push(out_datum.val);
|
||||
if out.is_rw {
|
||||
bcx = callee::trans_arg_datum(bcx,
|
||||
expr_ty(bcx, &*out.expr),
|
||||
expr_ty(bcx, &out.expr),
|
||||
out_datum,
|
||||
cleanup::CustomScope(temp_scope),
|
||||
callee::DontAutorefArg,
|
||||
|
|
@ -75,9 +75,9 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
|||
for &(ref c, ref input) in &ia.inputs {
|
||||
constraints.push((*c).clone());
|
||||
|
||||
let in_datum = unpack_datum!(bcx, expr::trans(bcx, &**input));
|
||||
let in_datum = unpack_datum!(bcx, expr::trans(bcx, &input));
|
||||
bcx = callee::trans_arg_datum(bcx,
|
||||
expr_ty(bcx, &**input),
|
||||
expr_ty(bcx, &input),
|
||||
in_datum,
|
||||
cleanup::CustomScope(temp_scope),
|
||||
callee::DontAutorefArg,
|
||||
|
|
@ -159,4 +159,3 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
|||
return bcx;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
let repr = adt::represent_type(cx.ccx(), t);
|
||||
let VariantInfo { fields, discr } = VariantInfo::from_ty(cx.tcx(), t, None);
|
||||
for (i, &Field(_, field_ty)) in fields.iter().enumerate() {
|
||||
let llfld_a = adt::trans_field_ptr(cx, &*repr, value, Disr::from(discr), i);
|
||||
let llfld_a = adt::trans_field_ptr(cx, &repr, value, Disr::from(discr), i);
|
||||
|
||||
let val = if common::type_is_sized(cx.tcx(), field_ty) {
|
||||
llfld_a
|
||||
|
|
@ -529,7 +529,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
ty::TyClosure(_, ref substs) => {
|
||||
let repr = adt::represent_type(cx.ccx(), t);
|
||||
for (i, upvar_ty) in substs.upvar_tys.iter().enumerate() {
|
||||
let llupvar = adt::trans_field_ptr(cx, &*repr, value, Disr(0), i);
|
||||
let llupvar = adt::trans_field_ptr(cx, &repr, value, Disr(0), i);
|
||||
cx = f(cx, llupvar, upvar_ty);
|
||||
}
|
||||
}
|
||||
|
|
@ -545,7 +545,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
ty::TyTuple(ref args) => {
|
||||
let repr = adt::represent_type(cx.ccx(), t);
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
let llfld_a = adt::trans_field_ptr(cx, &*repr, value, Disr(0), i);
|
||||
let llfld_a = adt::trans_field_ptr(cx, &repr, value, Disr(0), i);
|
||||
cx = f(cx, llfld_a, *arg);
|
||||
}
|
||||
}
|
||||
|
|
@ -559,11 +559,11 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
// NB: we must hit the discriminant first so that structural
|
||||
// comparison know not to proceed when the discriminants differ.
|
||||
|
||||
match adt::trans_switch(cx, &*repr, av, false) {
|
||||
match adt::trans_switch(cx, &repr, av, false) {
|
||||
(_match::Single, None) => {
|
||||
if n_variants != 0 {
|
||||
assert!(n_variants == 1);
|
||||
cx = iter_variant(cx, &*repr, adt::MaybeSizedValue::sized(av),
|
||||
cx = iter_variant(cx, &repr, adt::MaybeSizedValue::sized(av),
|
||||
&en.variants[0], substs, &mut f);
|
||||
}
|
||||
}
|
||||
|
|
@ -592,10 +592,10 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
let variant_cx = fcx.new_temp_block(&format!("enum-iter-variant-{}",
|
||||
&variant.disr_val
|
||||
.to_string()));
|
||||
let case_val = adt::trans_case(cx, &*repr, Disr::from(variant.disr_val));
|
||||
let case_val = adt::trans_case(cx, &repr, Disr::from(variant.disr_val));
|
||||
AddCase(llswitch, case_val, variant_cx.llbb);
|
||||
let variant_cx = iter_variant(variant_cx,
|
||||
&*repr,
|
||||
&repr,
|
||||
value,
|
||||
variant,
|
||||
substs,
|
||||
|
|
@ -1530,7 +1530,7 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo
|
|||
Some(hir_map::NodeExpr(ex)) => {
|
||||
if let hir::ExprRet(Some(ref ret_expr)) = ex.node {
|
||||
let mut visitor = FindNestedReturn::new();
|
||||
intravisit::walk_expr(&mut visitor, &**ret_expr);
|
||||
intravisit::walk_expr(&mut visitor, &ret_expr);
|
||||
if visitor.found {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2272,7 +2272,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
let repr = adt::represent_type(ccx, result_ty.unwrap());
|
||||
let mut llarg_idx = fcx.arg_offset() as c_uint;
|
||||
for (i, arg_ty) in arg_tys.into_iter().enumerate() {
|
||||
let lldestptr = adt::trans_field_ptr(bcx, &*repr, dest_val, Disr::from(disr), i);
|
||||
let lldestptr = adt::trans_field_ptr(bcx, &repr, dest_val, Disr::from(disr), i);
|
||||
if common::type_is_fat_ptr(bcx.tcx(), arg_ty) {
|
||||
Store(bcx,
|
||||
get_param(fcx.llfn, llarg_idx),
|
||||
|
|
@ -2292,7 +2292,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
}
|
||||
}
|
||||
}
|
||||
adt::trans_set_discr(bcx, &*repr, dest, disr);
|
||||
adt::trans_set_discr(bcx, &repr, dest, disr);
|
||||
}
|
||||
|
||||
finish_fn(&fcx, bcx, result_ty, DebugLoc::None);
|
||||
|
|
@ -2346,14 +2346,14 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span,
|
|||
|
||||
let sess = &ccx.tcx().sess;
|
||||
sess.span_note_without_error(sp,
|
||||
&*format!("total size: {} bytes", llsize_of_real(ccx, llty)));
|
||||
&format!("total size: {} bytes", llsize_of_real(ccx, llty)));
|
||||
match *avar {
|
||||
adt::General(..) => {
|
||||
for (i, var) in enum_def.variants.iter().enumerate() {
|
||||
ccx.tcx()
|
||||
.sess
|
||||
.span_note_without_error(var.span,
|
||||
&*format!("variant data: {} bytes", sizes[i]));
|
||||
&format!("variant data: {} bytes", sizes[i]));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -2505,8 +2505,8 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
|
|||
let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
|
||||
if abi != Abi::Rust {
|
||||
foreign::trans_rust_fn_with_foreign_abi(ccx,
|
||||
&**decl,
|
||||
&**body,
|
||||
&decl,
|
||||
&body,
|
||||
&item.attrs,
|
||||
llfn,
|
||||
empty_substs,
|
||||
|
|
@ -2514,8 +2514,8 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
|
|||
None);
|
||||
} else {
|
||||
trans_fn(ccx,
|
||||
&**decl,
|
||||
&**body,
|
||||
&decl,
|
||||
&body,
|
||||
llfn,
|
||||
empty_substs,
|
||||
item.id,
|
||||
|
|
@ -2837,11 +2837,11 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
hir::ForeignItemFn(..) => {
|
||||
let abi = ccx.tcx().map.get_foreign_abi(id);
|
||||
let ty = ccx.tcx().node_id_to_type(ni.id);
|
||||
let name = foreign::link_name(&*ni);
|
||||
let name = foreign::link_name(&ni);
|
||||
foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs)
|
||||
}
|
||||
hir::ForeignItemStatic(..) => {
|
||||
foreign::register_static(ccx, &*ni)
|
||||
foreign::register_static(ccx, &ni)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -755,7 +755,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let mut llargs = Vec::new();
|
||||
let arg_tys = match args {
|
||||
ArgExprs(a) => a.iter().map(|x| common::expr_ty_adjusted(bcx, &**x)).collect(),
|
||||
ArgExprs(a) => a.iter().map(|x| common::expr_ty_adjusted(bcx, &x)).collect(),
|
||||
_ => panic!("expected arg exprs.")
|
||||
};
|
||||
bcx = trans_args(bcx,
|
||||
|
|
@ -835,7 +835,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
|||
|
||||
// Translate the `self` argument first.
|
||||
if !ignore_self {
|
||||
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &*arg_exprs[0]));
|
||||
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &arg_exprs[0]));
|
||||
bcx = trans_arg_datum(bcx,
|
||||
args[0],
|
||||
arg_datum,
|
||||
|
|
@ -851,14 +851,14 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
|||
match tuple_type.sty {
|
||||
ty::TyTuple(ref field_types) => {
|
||||
let tuple_datum = unpack_datum!(bcx,
|
||||
expr::trans(bcx, &**tuple_expr));
|
||||
expr::trans(bcx, &tuple_expr));
|
||||
let tuple_lvalue_datum =
|
||||
unpack_datum!(bcx,
|
||||
tuple_datum.to_lvalue_datum(bcx,
|
||||
"args",
|
||||
tuple_expr.id));
|
||||
let repr = adt::represent_type(bcx.ccx(), tuple_type);
|
||||
let repr_ptr = &*repr;
|
||||
let repr_ptr = &repr;
|
||||
for (i, field_type) in field_types.iter().enumerate() {
|
||||
let arg_datum = tuple_lvalue_datum.get_element(
|
||||
bcx,
|
||||
|
|
@ -971,12 +971,12 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
let arg_ty = if i >= num_formal_args {
|
||||
assert!(variadic);
|
||||
common::expr_ty_adjusted(cx, &**arg_expr)
|
||||
common::expr_ty_adjusted(cx, &arg_expr)
|
||||
} else {
|
||||
arg_tys[i]
|
||||
};
|
||||
|
||||
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &**arg_expr));
|
||||
let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &arg_expr));
|
||||
bcx = trans_arg_datum(bcx, arg_ty, arg_datum,
|
||||
arg_cleanup_scope,
|
||||
DontAutorefArg,
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
|
|||
for (i, freevar) in freevars.iter().enumerate() {
|
||||
let datum = expr::trans_local_var(bcx, freevar.def);
|
||||
let upvar_slot_dest = adt::trans_field_ptr(
|
||||
bcx, &*repr, adt::MaybeSizedValue::sized(dest_addr), Disr(0), i);
|
||||
bcx, &repr, adt::MaybeSizedValue::sized(dest_addr), Disr(0), i);
|
||||
let upvar_id = ty::UpvarId { var_id: freevar.def.var_id(),
|
||||
closure_expr_id: id };
|
||||
match tcx.upvar_capture(upvar_id).unwrap() {
|
||||
|
|
@ -255,7 +255,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
adt::trans_set_discr(bcx, &*repr, dest_addr, Disr(0));
|
||||
adt::trans_set_discr(bcx, &repr, dest_addr, Disr(0));
|
||||
|
||||
Some(bcx)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ impl<'mir, 'tcx: 'mir> CachedMir<'mir, 'tcx> {
|
|||
fn get_ref<'a>(&'a self) -> &'a mir::Mir<'tcx> {
|
||||
match *self {
|
||||
CachedMir::Ref(r) => r,
|
||||
CachedMir::Owned(ref rc) => &**rc,
|
||||
CachedMir::Owned(ref rc) => &rc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ fn const_fn_call<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let substs = ccx.tcx().mk_substs(node_id_substs(ccx, node, param_substs));
|
||||
match fn_like.body().expr {
|
||||
Some(ref expr) => {
|
||||
const_expr(ccx, &**expr, substs, Some(&fn_args), trueconst).map(|(res, _)| res)
|
||||
const_expr(ccx, &expr, substs, Some(&fn_args), trueconst).map(|(res, _)| res)
|
||||
},
|
||||
None => Ok(C_nil(ccx)),
|
||||
}
|
||||
|
|
@ -570,7 +570,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
let map_list = |exprs: &[P<hir::Expr>]| -> Result<Vec<ValueRef>, ConstEvalFailure> {
|
||||
exprs.iter()
|
||||
.map(|e| const_expr(cx, &**e, param_substs, fn_args, trueconst).map(|(l, _)| l))
|
||||
.map(|e| const_expr(cx, &e, param_substs, fn_args, trueconst).map(|(l, _)| l))
|
||||
.collect::<Vec<Result<ValueRef, ConstEvalFailure>>>()
|
||||
.into_iter()
|
||||
.collect()
|
||||
|
|
@ -578,11 +578,11 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
};
|
||||
let _icx = push_ctxt("const_expr");
|
||||
Ok(match e.node {
|
||||
hir::ExprLit(ref lit) => const_lit(cx, e, &**lit),
|
||||
hir::ExprLit(ref lit) => const_lit(cx, e, &lit),
|
||||
hir::ExprBinary(b, ref e1, ref e2) => {
|
||||
/* Neither type is bottom, and we expect them to be unified
|
||||
* already, so the following is safe. */
|
||||
let (te1, ty) = try!(const_expr(cx, &**e1, param_substs, fn_args, trueconst));
|
||||
let (te1, ty) = try!(const_expr(cx, &e1, param_substs, fn_args, trueconst));
|
||||
debug!("const_expr_unadjusted: te1={}, ty={:?}",
|
||||
cx.tn().val_to_string(te1),
|
||||
ty);
|
||||
|
|
@ -590,7 +590,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let is_float = ty.is_fp();
|
||||
let signed = ty.is_signed();
|
||||
|
||||
let (te2, _) = try!(const_expr(cx, &**e2, param_substs, fn_args, trueconst));
|
||||
let (te2, _) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst));
|
||||
|
||||
try!(check_binary_expr_validity(cx, e, ty, te1, te2, trueconst));
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
} } // unsafe { match b.node {
|
||||
},
|
||||
hir::ExprUnary(u, ref inner_e) => {
|
||||
let (te, ty) = try!(const_expr(cx, &**inner_e, param_substs, fn_args, trueconst));
|
||||
let (te, ty) = try!(const_expr(cx, &inner_e, param_substs, fn_args, trueconst));
|
||||
|
||||
try!(check_unary_expr_validity(cx, e, ty, te, trueconst));
|
||||
|
||||
|
|
@ -651,20 +651,20 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
} }
|
||||
},
|
||||
hir::ExprField(ref base, field) => {
|
||||
let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst));
|
||||
let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst));
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
let ix = vinfo.field_index(field.node);
|
||||
adt::const_get_field(cx, &*brepr, bv, vinfo.discr, ix)
|
||||
adt::const_get_field(cx, &brepr, bv, vinfo.discr, ix)
|
||||
},
|
||||
hir::ExprTupField(ref base, idx) => {
|
||||
let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst));
|
||||
let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst));
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
adt::const_get_field(cx, &*brepr, bv, vinfo.discr, idx.node)
|
||||
adt::const_get_field(cx, &brepr, bv, vinfo.discr, idx.node)
|
||||
},
|
||||
hir::ExprIndex(ref base, ref index) => {
|
||||
let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst));
|
||||
let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst));
|
||||
let iv = match eval_const_expr_partial(cx.tcx(), &index, ExprTypeChecked, None) {
|
||||
Ok(ConstVal::Int(i)) => i as u64,
|
||||
Ok(ConstVal::Uint(u)) => u,
|
||||
|
|
@ -716,7 +716,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
hir::ExprCast(ref base, _) => {
|
||||
let t_cast = ety;
|
||||
let llty = type_of::type_of(cx, t_cast);
|
||||
let (v, t_expr) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst));
|
||||
let (v, t_expr) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst));
|
||||
debug!("trans_const_cast({:?} as {:?})", t_expr, t_cast);
|
||||
if expr::cast_is_noop(cx.tcx(), base, t_expr, t_cast) {
|
||||
return Ok(v);
|
||||
|
|
@ -741,9 +741,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
) {
|
||||
(CastTy::Int(IntTy::CEnum), CastTy::Int(_)) => {
|
||||
let repr = adt::represent_type(cx, t_expr);
|
||||
let discr = adt::const_get_discrim(cx, &*repr, v);
|
||||
let discr = adt::const_get_discrim(cx, &repr, v);
|
||||
let iv = C_integral(cx.int_type(), discr.0, false);
|
||||
let s = adt::is_discr_signed(&*repr) as Bool;
|
||||
let s = adt::is_discr_signed(&repr) as Bool;
|
||||
llvm::LLVMConstIntCast(iv, llty.to_ref(), s)
|
||||
},
|
||||
(CastTy::Int(_), CastTy::Int(_)) => {
|
||||
|
|
@ -798,18 +798,18 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
} else {
|
||||
// If this isn't the address of a static, then keep going through
|
||||
// normal constant evaluation.
|
||||
let (v, ty) = try!(const_expr(cx, &**sub, param_substs, fn_args, trueconst));
|
||||
let (v, ty) = try!(const_expr(cx, &sub, param_substs, fn_args, trueconst));
|
||||
addr_of(cx, v, type_of::align_of(cx, ty), "ref")
|
||||
}
|
||||
},
|
||||
hir::ExprAddrOf(hir::MutMutable, ref sub) => {
|
||||
let (v, ty) = try!(const_expr(cx, &**sub, param_substs, fn_args, trueconst));
|
||||
let (v, ty) = try!(const_expr(cx, &sub, param_substs, fn_args, trueconst));
|
||||
addr_of_mut(cx, v, type_of::align_of(cx, ty), "ref_mut_slice")
|
||||
},
|
||||
hir::ExprTup(ref es) => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
let vals = try!(map_list(&es[..]));
|
||||
adt::trans_const(cx, &*repr, Disr(0), &vals[..])
|
||||
adt::trans_const(cx, &repr, Disr(0), &vals[..])
|
||||
},
|
||||
hir::ExprStruct(_, ref fs, ref base_opt) => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
|
|
@ -817,7 +817,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let base_val = match *base_opt {
|
||||
Some(ref base) => Some(try!(const_expr(
|
||||
cx,
|
||||
&**base,
|
||||
&base,
|
||||
param_substs,
|
||||
fn_args,
|
||||
trueconst,
|
||||
|
|
@ -829,9 +829,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let cs = fields.iter().enumerate().map(|(ix, &Field(f_name, _))| {
|
||||
match (fs.iter().find(|f| f_name == f.name.node), base_val) {
|
||||
(Some(ref f), _) => {
|
||||
const_expr(cx, &*f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l)
|
||||
const_expr(cx, &f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l)
|
||||
},
|
||||
(_, Some((bv, _))) => Ok(adt::const_get_field(cx, &*repr, bv, discr, ix)),
|
||||
(_, Some((bv, _))) => Ok(adt::const_get_field(cx, &repr, bv, discr, ix)),
|
||||
(_, None) => cx.sess().span_bug(e.span, "missing struct field"),
|
||||
}
|
||||
})
|
||||
|
|
@ -842,7 +842,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
if ety.is_simd() {
|
||||
C_vector(&cs[..])
|
||||
} else {
|
||||
adt::trans_const(cx, &*repr, discr, &cs[..])
|
||||
adt::trans_const(cx, &repr, discr, &cs[..])
|
||||
}
|
||||
},
|
||||
hir::ExprVec(ref es) => {
|
||||
|
|
@ -851,7 +851,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let vs = es.iter()
|
||||
.map(|e| const_expr(
|
||||
cx,
|
||||
&**e,
|
||||
&e,
|
||||
param_substs,
|
||||
fn_args,
|
||||
trueconst,
|
||||
|
|
@ -871,7 +871,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let unit_ty = ety.sequence_element_type(cx.tcx());
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let n = cx.tcx().eval_repeat_count(count);
|
||||
let unit_val = try!(const_expr(cx, &**elem, param_substs, fn_args, trueconst)).0;
|
||||
let unit_val = try!(const_expr(cx, &elem, param_substs, fn_args, trueconst)).0;
|
||||
let vs = vec![unit_val; n];
|
||||
if val_ty(unit_val) != llunitty {
|
||||
C_struct(cx, &vs[..], false)
|
||||
|
|
@ -900,7 +900,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
match vinfo.kind() {
|
||||
ty::VariantKind::Unit => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
adt::trans_const(cx, &*repr, Disr::from(vinfo.disr_val), &[])
|
||||
adt::trans_const(cx, &repr, Disr::from(vinfo.disr_val), &[])
|
||||
}
|
||||
ty::VariantKind::Tuple => {
|
||||
expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val
|
||||
|
|
@ -930,7 +930,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
loop {
|
||||
callee = match callee.node {
|
||||
hir::ExprBlock(ref block) => match block.expr {
|
||||
Some(ref tail) => &**tail,
|
||||
Some(ref tail) => &tail,
|
||||
None => break,
|
||||
},
|
||||
_ => break,
|
||||
|
|
@ -954,14 +954,14 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
C_vector(&arg_vals[..])
|
||||
} else {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
adt::trans_const(cx, &*repr, Disr(0), &arg_vals[..])
|
||||
adt::trans_const(cx, &repr, Disr(0), &arg_vals[..])
|
||||
}
|
||||
}
|
||||
Def::Variant(enum_did, variant_did) => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
let vinfo = cx.tcx().lookup_adt_def(enum_did).variant_with_id(variant_did);
|
||||
adt::trans_const(cx,
|
||||
&*repr,
|
||||
&repr,
|
||||
Disr::from(vinfo.disr_val),
|
||||
&arg_vals[..])
|
||||
}
|
||||
|
|
@ -975,12 +975,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
try!(const_fn_call(cx, MethodCallKey(method_call),
|
||||
method_did, &arg_vals, param_substs, trueconst))
|
||||
},
|
||||
hir::ExprType(ref e, _) => try!(const_expr(cx, &**e, param_substs, fn_args, trueconst)).0,
|
||||
hir::ExprType(ref e, _) => try!(const_expr(cx, &e, param_substs, fn_args, trueconst)).0,
|
||||
hir::ExprBlock(ref block) => {
|
||||
match block.expr {
|
||||
Some(ref expr) => try!(const_expr(
|
||||
cx,
|
||||
&**expr,
|
||||
&expr,
|
||||
param_substs,
|
||||
fn_args,
|
||||
trueconst,
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
|
||||
match s.node {
|
||||
hir::StmtExpr(ref e, _) | hir::StmtSemi(ref e, _) => {
|
||||
bcx = trans_stmt_semi(bcx, &**e);
|
||||
bcx = trans_stmt_semi(bcx, &e);
|
||||
}
|
||||
hir::StmtDecl(ref d, _) => {
|
||||
match d.node {
|
||||
hir::DeclLocal(ref local) => {
|
||||
bcx = init_local(bcx, &**local);
|
||||
debuginfo::create_local_var_metadata(bcx, &**local);
|
||||
bcx = init_local(bcx, &local);
|
||||
debuginfo::create_local_var_metadata(bcx, &local);
|
||||
}
|
||||
// Inner items are visited by `trans_item`/`trans_meth`.
|
||||
hir::DeclItem(_) => {},
|
||||
|
|
@ -132,7 +132,7 @@ pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
match b.expr {
|
||||
Some(ref e) => {
|
||||
if !bcx.unreachable.get() {
|
||||
bcx = expr::trans_into(bcx, &**e, dest);
|
||||
bcx = expr::trans_into(bcx, &e, dest);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
|
@ -169,11 +169,11 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
if let Some(cv) = const_to_opt_uint(cond_val) {
|
||||
if cv == 1 {
|
||||
// if true { .. } [else { .. }]
|
||||
bcx = trans_block(bcx, &*thn, dest);
|
||||
bcx = trans_block(bcx, &thn, dest);
|
||||
trans::debuginfo::clear_source_location(bcx.fcx);
|
||||
} else {
|
||||
if let Some(elexpr) = els {
|
||||
bcx = expr::trans_into(bcx, &*elexpr, dest);
|
||||
bcx = expr::trans_into(bcx, &elexpr, dest);
|
||||
trans::debuginfo::clear_source_location(bcx.fcx);
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let name = format!("then-block-{}-", thn.id);
|
||||
let then_bcx_in = bcx.fcx.new_id_block(&name[..], thn.id);
|
||||
let then_bcx_out = trans_block(then_bcx_in, &*thn, dest);
|
||||
let then_bcx_out = trans_block(then_bcx_in, &thn, dest);
|
||||
trans::debuginfo::clear_source_location(bcx.fcx);
|
||||
|
||||
let cond_source_loc = cond.debug_loc();
|
||||
|
|
@ -192,7 +192,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
match els {
|
||||
Some(elexpr) => {
|
||||
let else_bcx_in = bcx.fcx.new_id_block("else-block", elexpr.id);
|
||||
let else_bcx_out = expr::trans_into(else_bcx_in, &*elexpr, dest);
|
||||
let else_bcx_out = expr::trans_into(else_bcx_in, &elexpr, dest);
|
||||
next_bcx = bcx.fcx.join_blocks(if_id,
|
||||
&[then_bcx_out, else_bcx_out]);
|
||||
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb, cond_source_loc);
|
||||
|
|
@ -365,13 +365,13 @@ pub fn trans_ret<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let mut bcx = bcx;
|
||||
let dest = match (fcx.llretslotptr.get(), retval_expr) {
|
||||
(Some(_), Some(retval_expr)) => {
|
||||
let ret_ty = expr_ty_adjusted(bcx, &*retval_expr);
|
||||
let ret_ty = expr_ty_adjusted(bcx, &retval_expr);
|
||||
expr::SaveIn(fcx.get_ret_slot(bcx, ty::FnConverging(ret_ty), "ret_slot"))
|
||||
}
|
||||
_ => expr::Ignore,
|
||||
};
|
||||
if let Some(x) = retval_expr {
|
||||
bcx = expr::trans_into(bcx, &*x, dest);
|
||||
bcx = expr::trans_into(bcx, &x, dest);
|
||||
match dest {
|
||||
expr::SaveIn(slot) if fcx.needs_ret_allocas => {
|
||||
Store(bcx, slot, fcx.llretslotptr.get().unwrap());
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ pub fn create_scope_map(cx: &CrateContext,
|
|||
// Push argument identifiers onto the stack so arguments integrate nicely
|
||||
// with variable shadowing.
|
||||
for arg in args {
|
||||
pat_util::pat_bindings_ident(def_map, &*arg.pat, |_, node_id, _, path1| {
|
||||
pat_util::pat_bindings_ident(def_map, &arg.pat, |_, node_id, _, path1| {
|
||||
scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata,
|
||||
name: Some(path1.node.unhygienic_name) });
|
||||
scope_map.insert(node_id, fn_metadata);
|
||||
|
|
@ -122,15 +122,15 @@ fn walk_block(cx: &CrateContext,
|
|||
|
||||
match statement.node {
|
||||
hir::StmtDecl(ref decl, _) =>
|
||||
walk_decl(cx, &**decl, scope_stack, scope_map),
|
||||
walk_decl(cx, &decl, scope_stack, scope_map),
|
||||
hir::StmtExpr(ref exp, _) |
|
||||
hir::StmtSemi(ref exp, _) =>
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map),
|
||||
walk_expr(cx, &exp, scope_stack, scope_map),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref exp) = block.expr {
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,10 +142,10 @@ fn walk_decl(cx: &CrateContext,
|
|||
codemap::Spanned { node: hir::DeclLocal(ref local), .. } => {
|
||||
scope_map.insert(local.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
walk_pattern(cx, &*local.pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &local.pat, scope_stack, scope_map);
|
||||
|
||||
if let Some(ref exp) = local.init {
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
|
@ -167,7 +167,7 @@ fn walk_pattern(cx: &CrateContext,
|
|||
|
||||
// Check if this is a binding. If so we need to put it on the
|
||||
// scope stack and maybe introduce an artificial scope
|
||||
if pat_util::pat_is_binding(&def_map.borrow(), &*pat) {
|
||||
if pat_util::pat_is_binding(&def_map.borrow(), &pat) {
|
||||
|
||||
let name = path1.node.unhygienic_name;
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ fn walk_pattern(cx: &CrateContext,
|
|||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
if let Some(ref sub_pat) = *sub_pat_opt {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ fn walk_pattern(cx: &CrateContext,
|
|||
|
||||
if let Some(ref sub_pats) = *sub_pats_opt {
|
||||
for p in sub_pats {
|
||||
walk_pattern(cx, &**p, scope_stack, scope_map);
|
||||
walk_pattern(cx, &p, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ fn walk_pattern(cx: &CrateContext,
|
|||
node: hir::FieldPat { pat: ref sub_pat, .. },
|
||||
..
|
||||
} in field_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,39 +268,39 @@ fn walk_pattern(cx: &CrateContext,
|
|||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
for sub_pat in sub_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
hir::PatBox(ref sub_pat) | hir::PatRegion(ref sub_pat, _) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::PatLit(ref exp) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::PatRange(ref exp1, ref exp2) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_expr(cx, &**exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &**exp2, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp2, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::PatVec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
for sub_pat in front_sub_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
if let Some(ref sub_pat) = *middle_sub_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
for sub_pat in back_sub_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -324,73 +324,73 @@ fn walk_expr(cx: &CrateContext,
|
|||
hir::ExprAddrOf(_, ref sub_exp) |
|
||||
hir::ExprField(ref sub_exp, _) |
|
||||
hir::ExprTupField(ref sub_exp, _) =>
|
||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||
walk_expr(cx, &sub_exp, scope_stack, scope_map),
|
||||
|
||||
hir::ExprBox(ref sub_expr) => {
|
||||
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
|
||||
walk_expr(cx, &sub_expr, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::ExprRet(ref exp_opt) => match *exp_opt {
|
||||
Some(ref sub_exp) => walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||
Some(ref sub_exp) => walk_expr(cx, &sub_exp, scope_stack, scope_map),
|
||||
None => ()
|
||||
},
|
||||
|
||||
hir::ExprUnary(_, ref sub_exp) => {
|
||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &sub_exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::ExprAssignOp(_, ref lhs, ref rhs) |
|
||||
hir::ExprIndex(ref lhs, ref rhs) |
|
||||
hir::ExprBinary(_, ref lhs, ref rhs) => {
|
||||
walk_expr(cx, &**lhs, scope_stack, scope_map);
|
||||
walk_expr(cx, &**rhs, scope_stack, scope_map);
|
||||
walk_expr(cx, &lhs, scope_stack, scope_map);
|
||||
walk_expr(cx, &rhs, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::ExprRange(ref start, ref end) => {
|
||||
start.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
||||
end.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
||||
start.as_ref().map(|e| walk_expr(cx, &e, scope_stack, scope_map));
|
||||
end.as_ref().map(|e| walk_expr(cx, &e, scope_stack, scope_map));
|
||||
}
|
||||
|
||||
hir::ExprVec(ref init_expressions) |
|
||||
hir::ExprTup(ref init_expressions) => {
|
||||
for ie in init_expressions {
|
||||
walk_expr(cx, &**ie, scope_stack, scope_map);
|
||||
walk_expr(cx, &ie, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprAssign(ref sub_exp1, ref sub_exp2) |
|
||||
hir::ExprRepeat(ref sub_exp1, ref sub_exp2) => {
|
||||
walk_expr(cx, &**sub_exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &**sub_exp2, scope_stack, scope_map);
|
||||
walk_expr(cx, &sub_exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &sub_exp2, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
hir::ExprIf(ref cond_exp, ref then_block, ref opt_else_exp) => {
|
||||
walk_expr(cx, &**cond_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &cond_exp, scope_stack, scope_map);
|
||||
|
||||
with_new_scope(cx,
|
||||
then_block.span,
|
||||
scope_stack,
|
||||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
walk_block(cx, &**then_block, scope_stack, scope_map);
|
||||
walk_block(cx, &then_block, scope_stack, scope_map);
|
||||
});
|
||||
|
||||
match *opt_else_exp {
|
||||
Some(ref else_exp) =>
|
||||
walk_expr(cx, &**else_exp, scope_stack, scope_map),
|
||||
walk_expr(cx, &else_exp, scope_stack, scope_map),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprWhile(ref cond_exp, ref loop_body, _) => {
|
||||
walk_expr(cx, &**cond_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &cond_exp, scope_stack, scope_map);
|
||||
|
||||
with_new_scope(cx,
|
||||
loop_body.span,
|
||||
scope_stack,
|
||||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
walk_block(cx, &**loop_body, scope_stack, scope_map);
|
||||
walk_block(cx, &loop_body, scope_stack, scope_map);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ fn walk_expr(cx: &CrateContext,
|
|||
scope_stack,
|
||||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
walk_block(cx, &**block, scope_stack, scope_map);
|
||||
walk_block(cx, &block, scope_stack, scope_map);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -412,29 +412,29 @@ fn walk_expr(cx: &CrateContext,
|
|||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
for &hir::Arg { pat: ref pattern, .. } in &decl.inputs {
|
||||
walk_pattern(cx, &**pattern, scope_stack, scope_map);
|
||||
walk_pattern(cx, &pattern, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
walk_block(cx, &**block, scope_stack, scope_map);
|
||||
walk_block(cx, &block, scope_stack, scope_map);
|
||||
})
|
||||
}
|
||||
|
||||
hir::ExprCall(ref fn_exp, ref args) => {
|
||||
walk_expr(cx, &**fn_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &fn_exp, scope_stack, scope_map);
|
||||
|
||||
for arg_exp in args {
|
||||
walk_expr(cx, &**arg_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &arg_exp, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
for arg_exp in args {
|
||||
walk_expr(cx, &**arg_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &arg_exp, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprMatch(ref discriminant_exp, ref arms, _) => {
|
||||
walk_expr(cx, &**discriminant_exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &discriminant_exp, scope_stack, scope_map);
|
||||
|
||||
// For each arm we have to first walk the pattern as these might
|
||||
// introduce new artificial scopes. It should be sufficient to
|
||||
|
|
@ -450,25 +450,25 @@ fn walk_expr(cx: &CrateContext,
|
|||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
for pat in &arm_ref.pats {
|
||||
walk_pattern(cx, &**pat, scope_stack, scope_map);
|
||||
walk_pattern(cx, &pat, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
if let Some(ref guard_exp) = arm_ref.guard {
|
||||
walk_expr(cx, &**guard_exp, scope_stack, scope_map)
|
||||
walk_expr(cx, &guard_exp, scope_stack, scope_map)
|
||||
}
|
||||
|
||||
walk_expr(cx, &*arm_ref.body, scope_stack, scope_map);
|
||||
walk_expr(cx, &arm_ref.body, scope_stack, scope_map);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprStruct(_, ref fields, ref base_exp) => {
|
||||
for &hir::Field { expr: ref exp, .. } in fields {
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
match *base_exp {
|
||||
Some(ref exp) => walk_expr(cx, &**exp, scope_stack, scope_map),
|
||||
Some(ref exp) => walk_expr(cx, &exp, scope_stack, scope_map),
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
|
@ -478,11 +478,11 @@ fn walk_expr(cx: &CrateContext,
|
|||
.. }) => {
|
||||
// inputs, outputs: Vec<(String, P<Expr>)>
|
||||
for &(_, ref exp) in inputs {
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
walk_expr(cx, &exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
for out in outputs {
|
||||
walk_expr(cx, &*out.expr, scope_stack, scope_map);
|
||||
walk_expr(cx, &out.expr, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1919,7 +1919,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &hir::Local) {
|
|||
let def_map = &cx.tcx().def_map;
|
||||
let locals = bcx.fcx.lllocals.borrow();
|
||||
|
||||
pat_util::pat_bindings(def_map, &*local.pat, |_, node_id, span, var_name| {
|
||||
pat_util::pat_bindings(def_map, &local.pat, |_, node_id, span, var_name| {
|
||||
let datum = match locals.get(&node_id) {
|
||||
Some(datum) => datum,
|
||||
None => {
|
||||
|
|
@ -2099,7 +2099,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &hir::Arg) {
|
|||
.fn_metadata;
|
||||
let locals = bcx.fcx.lllocals.borrow();
|
||||
|
||||
pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, span, var_name| {
|
||||
pat_util::pat_bindings(def_map, &arg.pat, |_, node_id, span, var_name| {
|
||||
let datum = match locals.get(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
let scope_map = create_scope_map::create_scope_map(cx,
|
||||
&fn_decl.inputs,
|
||||
&*top_level_block,
|
||||
&top_level_block,
|
||||
fn_metadata,
|
||||
fn_ast_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl NamespaceTreeNode {
|
|||
pub fn mangled_name_of_contained_item(&self, item_name: &str) -> String {
|
||||
fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
|
||||
match node.parent {
|
||||
Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output),
|
||||
Some(ref parent) => fill_nested(&parent.upgrade().unwrap(), output),
|
||||
None => {}
|
||||
}
|
||||
let string = node.name.as_str();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
|
|||
|
||||
pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
|
||||
attributes.iter().any(|attr| {
|
||||
let meta_item: &ast::MetaItem = &*attr.node.value;
|
||||
let meta_item: &ast::MetaItem = &attr.node.value;
|
||||
match meta_item.node {
|
||||
ast::MetaItemKind::Word(ref value) => &value[..] == "no_debug",
|
||||
_ => false
|
||||
|
|
|
|||
|
|
@ -650,39 +650,39 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
match expr.node {
|
||||
hir::ExprType(ref e, _) => {
|
||||
trans(bcx, &**e)
|
||||
trans(bcx, &e)
|
||||
}
|
||||
hir::ExprPath(..) => {
|
||||
trans_def(bcx, expr, bcx.def(expr.id))
|
||||
}
|
||||
hir::ExprField(ref base, name) => {
|
||||
trans_rec_field(bcx, &**base, name.node)
|
||||
trans_rec_field(bcx, &base, name.node)
|
||||
}
|
||||
hir::ExprTupField(ref base, idx) => {
|
||||
trans_rec_tup_field(bcx, &**base, idx.node)
|
||||
trans_rec_tup_field(bcx, &base, idx.node)
|
||||
}
|
||||
hir::ExprIndex(ref base, ref idx) => {
|
||||
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
|
||||
trans_index(bcx, expr, &base, &idx, MethodCall::expr(expr.id))
|
||||
}
|
||||
hir::ExprBox(ref contents) => {
|
||||
// Special case for `Box<T>`
|
||||
let box_ty = expr_ty(bcx, expr);
|
||||
let contents_ty = expr_ty(bcx, &**contents);
|
||||
let contents_ty = expr_ty(bcx, &contents);
|
||||
match box_ty.sty {
|
||||
ty::TyBox(..) => {
|
||||
trans_uniq_expr(bcx, expr, box_ty, &**contents, contents_ty)
|
||||
trans_uniq_expr(bcx, expr, box_ty, &contents, contents_ty)
|
||||
}
|
||||
_ => bcx.sess().span_bug(expr.span,
|
||||
"expected unique box")
|
||||
}
|
||||
|
||||
}
|
||||
hir::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &**lit),
|
||||
hir::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &lit),
|
||||
hir::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
trans_binary(bcx, expr, op, &**lhs, &**rhs)
|
||||
trans_binary(bcx, expr, op, &lhs, &rhs)
|
||||
}
|
||||
hir::ExprUnary(op, ref x) => {
|
||||
trans_unary(bcx, expr, op, &**x)
|
||||
trans_unary(bcx, expr, op, &x)
|
||||
}
|
||||
hir::ExprAddrOf(_, ref x) => {
|
||||
match x.node {
|
||||
|
|
@ -695,18 +695,18 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
false);
|
||||
fcx.push_ast_cleanup_scope(cleanup_debug_loc);
|
||||
let datum = unpack_datum!(
|
||||
bcx, tvec::trans_slice_vec(bcx, expr, &**x));
|
||||
bcx, tvec::trans_slice_vec(bcx, expr, &x));
|
||||
bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, x.id);
|
||||
DatumBlock::new(bcx, datum)
|
||||
}
|
||||
_ => {
|
||||
trans_addr_of(bcx, expr, &**x)
|
||||
trans_addr_of(bcx, expr, &x)
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ExprCast(ref val, _) => {
|
||||
// Datum output mode means this is a scalar cast:
|
||||
trans_imm_cast(bcx, &**val, expr.id)
|
||||
trans_imm_cast(bcx, &val, expr.id)
|
||||
}
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
|
|
@ -737,7 +737,7 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
bcx,
|
||||
vinfo.fields[ix].1,
|
||||
|srcval| {
|
||||
adt::trans_field_ptr(bcx, &*repr, srcval, vinfo.discr, ix)
|
||||
adt::trans_field_ptr(bcx, &repr, srcval, vinfo.discr, ix)
|
||||
});
|
||||
|
||||
if type_is_sized(bcx.tcx(), d.ty) {
|
||||
|
|
@ -938,7 +938,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node.name))
|
||||
}
|
||||
hir::ExprType(ref e, _) => {
|
||||
trans_into(bcx, &**e, Ignore)
|
||||
trans_into(bcx, &e, Ignore)
|
||||
}
|
||||
hir::ExprAgain(label_opt) => {
|
||||
controlflow::trans_cont(bcx, expr, label_opt.map(|l| l.node.name))
|
||||
|
|
@ -959,7 +959,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// directly. This avoids having to manage a return slot when
|
||||
// it won't actually be used anyway.
|
||||
if let &Some(ref x) = ex {
|
||||
bcx = trans_into(bcx, &**x, Ignore);
|
||||
bcx = trans_into(bcx, &x, Ignore);
|
||||
}
|
||||
// Mark the end of the block as unreachable. Once we get to
|
||||
// a return expression, there's no more we should be doing
|
||||
|
|
@ -969,14 +969,14 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
hir::ExprWhile(ref cond, ref body, _) => {
|
||||
controlflow::trans_while(bcx, expr, &**cond, &**body)
|
||||
controlflow::trans_while(bcx, expr, &cond, &body)
|
||||
}
|
||||
hir::ExprLoop(ref body, _) => {
|
||||
controlflow::trans_loop(bcx, expr, &**body)
|
||||
controlflow::trans_loop(bcx, expr, &body)
|
||||
}
|
||||
hir::ExprAssign(ref dst, ref src) => {
|
||||
let src_datum = unpack_datum!(bcx, trans(bcx, &**src));
|
||||
let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &**dst, "assign"));
|
||||
let src_datum = unpack_datum!(bcx, trans(bcx, &src));
|
||||
let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &dst, "assign"));
|
||||
|
||||
if bcx.fcx.type_needs_drop(dst_datum.ty) {
|
||||
// If there are destructors involved, make sure we
|
||||
|
|
@ -1031,12 +1031,12 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
.contains_key(&MethodCall::expr(expr.id));
|
||||
|
||||
if has_method_map {
|
||||
let dst = unpack_datum!(bcx, trans(bcx, &**dst));
|
||||
let src_datum = unpack_datum!(bcx, trans(bcx, &**src));
|
||||
let dst = unpack_datum!(bcx, trans(bcx, &dst));
|
||||
let src_datum = unpack_datum!(bcx, trans(bcx, &src));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), dst,
|
||||
Some((src_datum, src.id)), None, false).bcx
|
||||
} else {
|
||||
trans_assign_op(bcx, expr, op, &**dst, &**src)
|
||||
trans_assign_op(bcx, expr, op, &dst, &src)
|
||||
}
|
||||
}
|
||||
hir::ExprInlineAsm(ref a) => {
|
||||
|
|
@ -1064,19 +1064,19 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
match expr.node {
|
||||
hir::ExprType(ref e, _) => {
|
||||
trans_into(bcx, &**e, dest)
|
||||
trans_into(bcx, &e, dest)
|
||||
}
|
||||
hir::ExprPath(..) => {
|
||||
trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest)
|
||||
}
|
||||
hir::ExprIf(ref cond, ref thn, ref els) => {
|
||||
controlflow::trans_if(bcx, expr.id, &**cond, &**thn, els.as_ref().map(|e| &**e), dest)
|
||||
controlflow::trans_if(bcx, expr.id, &cond, &thn, els.as_ref().map(|e| &**e), dest)
|
||||
}
|
||||
hir::ExprMatch(ref discr, ref arms, _) => {
|
||||
_match::trans_match(bcx, expr, &**discr, &arms[..], dest)
|
||||
_match::trans_match(bcx, expr, &discr, &arms[..], dest)
|
||||
}
|
||||
hir::ExprBlock(ref blk) => {
|
||||
controlflow::trans_block(bcx, &**blk, dest)
|
||||
controlflow::trans_block(bcx, &blk, dest)
|
||||
}
|
||||
hir::ExprStruct(_, ref fields, ref base) => {
|
||||
trans_struct(bcx,
|
||||
|
|
@ -1201,13 +1201,13 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
if bcx.tcx().is_method_call(expr.id) {
|
||||
trans_overloaded_call(bcx,
|
||||
expr,
|
||||
&**f,
|
||||
&f,
|
||||
&args[..],
|
||||
Some(dest))
|
||||
} else {
|
||||
callee::trans_call(bcx,
|
||||
expr,
|
||||
&**f,
|
||||
&f,
|
||||
callee::ArgExprs(&args[..]),
|
||||
dest)
|
||||
}
|
||||
|
|
@ -1215,28 +1215,28 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
callee::trans_method_call(bcx,
|
||||
expr,
|
||||
&*args[0],
|
||||
&args[0],
|
||||
callee::ArgExprs(&args[..]),
|
||||
dest)
|
||||
}
|
||||
hir::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let lhs = unpack_datum!(bcx, trans(bcx, &**lhs));
|
||||
let rhs_datum = unpack_datum!(bcx, trans(bcx, &**rhs));
|
||||
let lhs = unpack_datum!(bcx, trans(bcx, &lhs));
|
||||
let rhs_datum = unpack_datum!(bcx, trans(bcx, &rhs));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), lhs,
|
||||
Some((rhs_datum, rhs.id)), Some(dest),
|
||||
!rustc_front::util::is_by_value_binop(op.node)).bcx
|
||||
}
|
||||
hir::ExprUnary(op, ref subexpr) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let arg = unpack_datum!(bcx, trans(bcx, &**subexpr));
|
||||
let arg = unpack_datum!(bcx, trans(bcx, &subexpr));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id),
|
||||
arg, None, Some(dest), !rustc_front::util::is_by_value_unop(op)).bcx
|
||||
}
|
||||
hir::ExprIndex(ref base, ref idx) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let base = unpack_datum!(bcx, trans(bcx, &**base));
|
||||
let idx_datum = unpack_datum!(bcx, trans(bcx, &**idx));
|
||||
let base = unpack_datum!(bcx, trans(bcx, &base));
|
||||
let idx_datum = unpack_datum!(bcx, trans(bcx, &idx));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base,
|
||||
Some((idx_datum, idx.id)), Some(dest), true).bcx
|
||||
}
|
||||
|
|
@ -1286,7 +1286,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// Nullary variant.
|
||||
let ty = expr_ty(bcx, ref_expr);
|
||||
let repr = adt::represent_type(bcx.ccx(), ty);
|
||||
adt::trans_set_discr(bcx, &*repr, lldest, Disr::from(variant.disr_val));
|
||||
adt::trans_set_discr(bcx, &repr, lldest, Disr::from(variant.disr_val));
|
||||
return bcx;
|
||||
}
|
||||
}
|
||||
|
|
@ -1295,7 +1295,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
match ty.sty {
|
||||
ty::TyStruct(def, _) if def.has_dtor() => {
|
||||
let repr = adt::represent_type(bcx.ccx(), ty);
|
||||
adt::trans_set_discr(bcx, &*repr, lldest, Disr(0));
|
||||
adt::trans_set_discr(bcx, &repr, lldest, Disr(0));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -1505,7 +1505,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
let mut vec_val = C_undef(llty);
|
||||
|
||||
for &(i, ref e) in fields {
|
||||
let block_datum = trans(bcx, &**e);
|
||||
let block_datum = trans(bcx, &e);
|
||||
bcx = block_datum.bcx;
|
||||
let position = C_uint(bcx.ccx(), i);
|
||||
let value = block_datum.datum.to_llscalarish(bcx);
|
||||
|
|
@ -1518,7 +1518,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
|
||||
// First, trans field expressions to temporary scratch values.
|
||||
let scratch_vals: Vec<_> = fields.iter().map(|&(i, ref e)| {
|
||||
let datum = unpack_datum!(bcx, trans(bcx, &**e));
|
||||
let datum = unpack_datum!(bcx, trans(bcx, &e));
|
||||
(i, datum)
|
||||
}).collect();
|
||||
|
||||
|
|
@ -1528,20 +1528,20 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
assert_eq!(discr, Disr(0));
|
||||
|
||||
let addr = adt::MaybeSizedValue::sized(addr);
|
||||
match expr_kind(bcx.tcx(), &*base.expr) {
|
||||
match expr_kind(bcx.tcx(), &base.expr) {
|
||||
ExprKind::RvalueDps | ExprKind::RvalueDatum if !bcx.fcx.type_needs_drop(ty) => {
|
||||
bcx = trans_into(bcx, &*base.expr, SaveIn(addr.value));
|
||||
bcx = trans_into(bcx, &base.expr, SaveIn(addr.value));
|
||||
},
|
||||
ExprKind::RvalueStmt => {
|
||||
bcx.tcx().sess.bug("unexpected expr kind for struct base expr")
|
||||
}
|
||||
_ => {
|
||||
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base"));
|
||||
let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &base.expr, "base"));
|
||||
for &(i, t) in &base.fields {
|
||||
let datum = base_datum.get_element(
|
||||
bcx, t, |srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, i));
|
||||
bcx, t, |srcval| adt::trans_field_ptr(bcx, &repr, srcval, discr, i));
|
||||
assert!(type_is_sized(bcx.tcx(), datum.ty));
|
||||
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
|
||||
let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i);
|
||||
bcx = datum.store_to(bcx, dest);
|
||||
}
|
||||
}
|
||||
|
|
@ -1549,16 +1549,16 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
|
||||
// Finally, move scratch field values into actual field locations
|
||||
for (i, datum) in scratch_vals {
|
||||
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
|
||||
let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i);
|
||||
bcx = datum.store_to(bcx, dest);
|
||||
}
|
||||
} else {
|
||||
// No base means we can write all fields directly in place.
|
||||
let addr = adt::MaybeSizedValue::sized(addr);
|
||||
for &(i, ref e) in fields {
|
||||
let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i);
|
||||
let e_ty = expr_ty_adjusted(bcx, &**e);
|
||||
bcx = trans_into(bcx, &**e, SaveIn(dest));
|
||||
let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i);
|
||||
let e_ty = expr_ty_adjusted(bcx, &e);
|
||||
bcx = trans_into(bcx, &e, SaveIn(dest));
|
||||
let scope = cleanup::CustomScope(custom_cleanup_scope);
|
||||
fcx.schedule_lifetime_end(scope, dest);
|
||||
// FIXME: nonzeroing move should generalize to fields
|
||||
|
|
@ -1566,7 +1566,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
adt::trans_set_discr(bcx, &*repr, addr, discr);
|
||||
adt::trans_set_discr(bcx, &repr, addr, discr);
|
||||
|
||||
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
|
||||
|
||||
|
|
@ -2112,10 +2112,10 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let datum = unpack_datum!(
|
||||
bcx, datum.to_lvalue_datum(bcx, "trans_imm_cast", expr.id));
|
||||
let llexpr_ptr = datum.to_llref();
|
||||
let discr = adt::trans_get_discr(bcx, &*repr, llexpr_ptr,
|
||||
let discr = adt::trans_get_discr(bcx, &repr, llexpr_ptr,
|
||||
Some(Type::i64(ccx)), true);
|
||||
ll_t_in = val_ty(discr);
|
||||
(discr, adt::is_discr_signed(&*repr))
|
||||
(discr, adt::is_discr_signed(&repr))
|
||||
} else {
|
||||
(datum.to_llscalarish(bcx), t_in.is_signed())
|
||||
};
|
||||
|
|
@ -2165,7 +2165,7 @@ fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let lhs = immediate_rvalue(lhs, dst.ty);
|
||||
|
||||
// Evaluate RHS - FIXME(#28160) this sucks
|
||||
let rhs = unpack_datum!(bcx, trans(bcx, &*src));
|
||||
let rhs = unpack_datum!(bcx, trans(bcx, &src));
|
||||
let rhs = unpack_datum!(bcx, rhs.to_rvalue_datum(bcx, "assign_op_rhs"));
|
||||
|
||||
// Perform computation and store the result
|
||||
|
|
|
|||
|
|
@ -472,10 +472,10 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) {
|
|||
};
|
||||
let sig = &ty.sig.0;
|
||||
for (input, ty) in decl.inputs.iter().zip(&sig.inputs) {
|
||||
check(&*input.ty, *ty)
|
||||
check(&input.ty, *ty)
|
||||
}
|
||||
if let hir::Return(ref ty) = decl.output {
|
||||
check(&**ty, sig.output.unwrap())
|
||||
check(&ty, sig.output.unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) {
|
|||
abi => {
|
||||
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
|
||||
match ty.sty {
|
||||
ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &**decl, bft),
|
||||
ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &decl, bft),
|
||||
_ => ccx.tcx().sess.span_bug(foreign_item.span,
|
||||
"foreign fn's sty isn't a bare_fn_ty?")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
assert!(type_is_sized(bcx.tcx(), t), "Precondition: caller must ensure t is sized");
|
||||
|
||||
let repr = adt::represent_type(bcx.ccx(), t);
|
||||
let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &*repr, struct_data));
|
||||
let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &repr, struct_data));
|
||||
let loaded = load_ty(bcx, drop_flag.val, bcx.tcx().dtor_type());
|
||||
let drop_flag_llty = type_of(bcx.fcx.ccx, bcx.tcx().dtor_type());
|
||||
let init_val = C_integral(drop_flag_llty, adt::DTOR_NEEDED as u64, false);
|
||||
|
|
@ -402,7 +402,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
|
|||
// Don't use type_of::sizing_type_of because that expects t to be sized.
|
||||
assert!(!t.is_simd());
|
||||
let repr = adt::represent_type(ccx, t);
|
||||
let sizing_type = adt::sizing_type_context_of(ccx, &*repr, true);
|
||||
let sizing_type = adt::sizing_type_context_of(ccx, &repr, true);
|
||||
debug!("DST {} sizing_type: {}", t, sizing_type.to_string());
|
||||
let sized_size = llsize_of_alloc(ccx, sizing_type.prefix());
|
||||
let sized_align = llalign_of_min(ccx, sizing_type.prefix());
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId) -> Option<DefId> {
|
|||
_ => ccx.sess().bug("instantiate_inline: item has a \
|
||||
non-enum, non-struct parent")
|
||||
}
|
||||
trans_item(ccx, &**item);
|
||||
trans_item(ccx, &item);
|
||||
my_id
|
||||
}
|
||||
FoundAst::FoundParent(_, _) => {
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
// efficient (these are done efficiently implicitly in C
|
||||
// with the `__m128i` type and so this means Rust doesn't
|
||||
// lose out there).
|
||||
let expr = &*arg_exprs[0];
|
||||
let expr = &arg_exprs[0];
|
||||
let datum = unpack_datum!(bcx, expr::trans(bcx, expr));
|
||||
let datum = unpack_datum!(bcx, datum.to_rvalue_datum(bcx, "transmute_temp"));
|
||||
let val = if datum.kind.is_by_ref() {
|
||||
|
|
@ -253,7 +253,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
expr::SaveIn(d) => expr::SaveIn(PointerCast(bcx, d, llintype.ptr_to())),
|
||||
expr::Ignore => expr::Ignore
|
||||
};
|
||||
bcx = expr::trans_into(bcx, &*arg_exprs[0], dest);
|
||||
bcx = expr::trans_into(bcx, &arg_exprs[0], dest);
|
||||
dest
|
||||
};
|
||||
|
||||
|
|
@ -404,7 +404,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
};
|
||||
|
||||
let simple = get_simple_intrinsic(ccx, &*foreign_item);
|
||||
let simple = get_simple_intrinsic(ccx, &foreign_item);
|
||||
let llval = match (simple, &*name) {
|
||||
(Some(llfn), _) => {
|
||||
Call(bcx, llfn, &llargs, None, call_debug_location)
|
||||
|
|
@ -658,7 +658,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
match val_ty.sty {
|
||||
ty::TyEnum(..) => {
|
||||
let repr = adt::represent_type(ccx, *val_ty);
|
||||
adt::trans_get_discr(bcx, &*repr, llargs[0],
|
||||
adt::trans_get_discr(bcx, &repr, llargs[0],
|
||||
Some(llret_ty), true)
|
||||
}
|
||||
_ => C_null(llret_ty)
|
||||
|
|
@ -849,7 +849,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
assert!(!bcx.fcx.type_needs_drop(arg_type));
|
||||
|
||||
let repr = adt::represent_type(bcx.ccx(), arg_type);
|
||||
let repr_ptr = &*repr;
|
||||
let repr_ptr = &repr;
|
||||
let arg = adt::MaybeSizedValue::sized(llarg);
|
||||
(0..contents.len())
|
||||
.map(|i| {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
assert_eq!(adt_def.variants.len(), targets.len());
|
||||
for (adt_variant, target) in adt_def.variants.iter().zip(targets) {
|
||||
let llval = bcx.with_block(|bcx|
|
||||
adt::trans_case(bcx, &*repr, Disr::from(adt_variant.disr_val))
|
||||
adt::trans_case(bcx, &repr, Disr::from(adt_variant.disr_val))
|
||||
);
|
||||
let llbb = self.llblock(*target);
|
||||
build::AddCase(switch, llval, llbb)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
let repr = adt::represent_type(bcx.ccx(), dest.ty.to_ty(bcx.tcx()));
|
||||
let disr = Disr::from(adt_def.variants[index].disr_val);
|
||||
bcx.with_block(|bcx| {
|
||||
adt::trans_set_discr(bcx, &*repr, dest.llval, Disr::from(disr));
|
||||
adt::trans_set_discr(bcx, &repr, dest.llval, Disr::from(disr));
|
||||
});
|
||||
for (i, operand) in operands.iter().enumerate() {
|
||||
let op = self.trans_operand(&bcx, operand);
|
||||
|
|
@ -114,7 +114,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
if !common::type_is_zero_size(bcx.ccx(), op.ty) {
|
||||
let val = adt::MaybeSizedValue::sized(dest.llval);
|
||||
let lldest_i = bcx.with_block(|bcx| {
|
||||
adt::trans_field_ptr(bcx, &*repr, val, disr, i)
|
||||
adt::trans_field_ptr(bcx, &repr, val, disr, i)
|
||||
});
|
||||
self.store_operand(&bcx, lldest_i, op);
|
||||
}
|
||||
|
|
@ -234,9 +234,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
let repr = adt::represent_type(bcx.ccx(), operand.ty);
|
||||
let llval = operand.immediate();
|
||||
let discr = bcx.with_block(|bcx| {
|
||||
adt::trans_get_discr(bcx, &*repr, llval, None, true)
|
||||
adt::trans_get_discr(bcx, &repr, llval, None, true)
|
||||
});
|
||||
(discr, common::val_ty(discr), adt::is_discr_signed(&*repr))
|
||||
(discr, common::val_ty(discr), adt::is_discr_signed(&repr))
|
||||
} else {
|
||||
(operand.immediate(), ll_t_in, operand.ty.is_signed())
|
||||
};
|
||||
|
|
|
|||
|
|
@ -183,12 +183,12 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
if needs_body {
|
||||
if abi != Abi::Rust {
|
||||
foreign::trans_rust_fn_with_foreign_abi(
|
||||
ccx, &**decl, &**body, &[], d, psubsts, fn_node_id,
|
||||
ccx, &decl, &body, &[], d, psubsts, fn_node_id,
|
||||
Some(&hash[..]));
|
||||
} else {
|
||||
trans_fn(ccx,
|
||||
&**decl,
|
||||
&**body,
|
||||
&decl,
|
||||
&body,
|
||||
d,
|
||||
psubsts,
|
||||
fn_node_id,
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
match dest {
|
||||
Ignore => {
|
||||
for element in elements {
|
||||
bcx = expr::trans_into(bcx, &**element, Ignore);
|
||||
bcx = expr::trans_into(bcx, &element, Ignore);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let lleltptr = GEPi(bcx, lldest, &[i]);
|
||||
debug!("writing index {} with lleltptr={}",
|
||||
i, bcx.val_to_string(lleltptr));
|
||||
bcx = expr::trans_into(bcx, &**element,
|
||||
bcx = expr::trans_into(bcx, &element,
|
||||
SaveIn(lleltptr));
|
||||
let scope = cleanup::CustomScope(temp_scope);
|
||||
// Issue #30822: mark memory as dropped after running destructor
|
||||
|
|
@ -230,14 +230,14 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
hir::ExprRepeat(ref element, ref count_expr) => {
|
||||
match dest {
|
||||
Ignore => {
|
||||
return expr::trans_into(bcx, &**element, Ignore);
|
||||
return expr::trans_into(bcx, &element, Ignore);
|
||||
}
|
||||
SaveIn(lldest) => {
|
||||
match bcx.tcx().eval_repeat_count(&**count_expr) {
|
||||
0 => expr::trans_into(bcx, &**element, Ignore),
|
||||
1 => expr::trans_into(bcx, &**element, SaveIn(lldest)),
|
||||
match bcx.tcx().eval_repeat_count(&count_expr) {
|
||||
0 => expr::trans_into(bcx, &element, Ignore),
|
||||
1 => expr::trans_into(bcx, &element, SaveIn(lldest)),
|
||||
count => {
|
||||
let elem = unpack_datum!(bcx, expr::trans(bcx, &**element));
|
||||
let elem = unpack_datum!(bcx, expr::trans(bcx, &element));
|
||||
let bcx = iter_vec_loop(bcx, lldest, vt,
|
||||
C_uint(bcx.ccx(), count),
|
||||
|set_bcx, lleltptr, _| {
|
||||
|
|
@ -285,7 +285,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
|||
},
|
||||
hir::ExprVec(ref es) => es.len(),
|
||||
hir::ExprRepeat(_, ref count_expr) => {
|
||||
bcx.tcx().eval_repeat_count(&**count_expr)
|
||||
bcx.tcx().eval_repeat_count(&count_expr)
|
||||
}
|
||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected vec content")
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||
|
||||
ty::TyTuple(..) | ty::TyEnum(..) | ty::TyClosure(..) => {
|
||||
let repr = adt::represent_type(cx, t);
|
||||
adt::sizing_type_of(cx, &*repr, false)
|
||||
adt::sizing_type_of(cx, &repr, false)
|
||||
}
|
||||
|
||||
ty::TyStruct(..) => {
|
||||
|
|
@ -243,7 +243,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||
Type::vector(&llet, n)
|
||||
} else {
|
||||
let repr = adt::represent_type(cx, t);
|
||||
adt::sizing_type_of(cx, &*repr, false)
|
||||
adt::sizing_type_of(cx, &repr, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
let repr = adt::represent_type(cx, t);
|
||||
let tps = substs.types.get_slice(subst::TypeSpace);
|
||||
let name = llvm_type_name(cx, def.did, tps);
|
||||
adt::incomplete_type_of(cx, &*repr, &name[..])
|
||||
adt::incomplete_type_of(cx, &repr, &name[..])
|
||||
}
|
||||
ty::TyClosure(..) => {
|
||||
// Only create the named struct, but don't fill it in. We
|
||||
|
|
@ -369,7 +369,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
// inherited from their environment, so we use entire
|
||||
// contents of the VecPerParamSpace to construct the llvm
|
||||
// name
|
||||
adt::incomplete_type_of(cx, &*repr, "closure")
|
||||
adt::incomplete_type_of(cx, &repr, "closure")
|
||||
}
|
||||
|
||||
ty::TyBox(ty) |
|
||||
|
|
@ -423,7 +423,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
ty::TyTuple(ref tys) if tys.is_empty() => Type::nil(cx),
|
||||
ty::TyTuple(..) => {
|
||||
let repr = adt::represent_type(cx, t);
|
||||
adt::type_of(cx, &*repr)
|
||||
adt::type_of(cx, &repr)
|
||||
}
|
||||
ty::TyStruct(def, ref substs) => {
|
||||
if t.is_simd() {
|
||||
|
|
@ -444,7 +444,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
let repr = adt::represent_type(cx, t);
|
||||
let tps = substs.types.get_slice(subst::TypeSpace);
|
||||
let name = llvm_type_name(cx, def.did, tps);
|
||||
adt::incomplete_type_of(cx, &*repr, &name[..])
|
||||
adt::incomplete_type_of(cx, &repr, &name[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
ty::TyEnum(..) | ty::TyStruct(..) | ty::TyClosure(..)
|
||||
if !t.is_simd() => {
|
||||
let repr = adt::represent_type(cx, t);
|
||||
adt::finish_type_of(cx, &*repr, &mut llty);
|
||||
adt::finish_type_of(cx, &repr, &mut llty);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue