pub fn with_scope_result(bcx: block,
opt_node_info: Option<NodeInfo>,
- name: &str,
+ _name: &str,
f: &fn(block) -> Result) -> Result {
let _icx = push_ctxt("with_scope_result");
impl_id: ast::def_id)
-> typeck::vtable_res {
if impl_id.crate == ast::local_crate {
- *bcx.ccx().maps.vtable_map.get(&impl_id.node)
+ bcx.ccx().maps.vtable_map.get_copy(&impl_id.node)
} else {
// XXX: This is a temporary hack to work around not properly
// exporting information about resolutions for impls.
None => { assert!(ty::type_is_immediate(bcx.tcx(), ret_ty)) }
Some(expr::Ignore) => {
// drop the value if it is not being saved.
- unsafe {
- if ty::type_needs_drop(bcx.tcx(), ret_ty) {
- if ty::type_is_immediate(bcx.tcx(), ret_ty) {
- let llscratchptr = alloc_ty(bcx, ret_ty, "__ret");
- Store(bcx, llresult, llscratchptr);
- bcx = glue::drop_ty(bcx, llscratchptr, ret_ty);
- } else {
- bcx = glue::drop_ty(bcx, llretslot, ret_ty);
- }
+ if ty::type_needs_drop(bcx.tcx(), ret_ty) {
+ if ty::type_is_immediate(bcx.tcx(), ret_ty) {
+ let llscratchptr = alloc_ty(bcx, ret_ty, "__ret");
+ Store(bcx, llresult, llscratchptr);
+ bcx = glue::drop_ty(bcx, llscratchptr, ret_ty);
+ } else {
+ bcx = glue::drop_ty(bcx, llretslot, ret_ty);
}
}
}
// Locate closest loop block, outputting cleanup as we go.
let mut unwind = bcx;
let mut cur_scope = unwind.scope;
- let mut target = unwind;
+ let mut target;
loop {
cur_scope = match cur_scope {
Some(@scope_info {
}
pub fn impl_trait_ref(cx: ctxt, id: ast::def_id) -> Option<@TraitRef> {
- *do cx.impl_trait_cache.find_or_insert_with(id) |_| {
- if id.crate == ast::local_crate {
- debug!("(impl_trait_ref) searching for trait impl %?", id);
- match cx.items.find(&id.node) {
- Some(&ast_map::node_item(@ast::item {
- node: ast::item_impl(_, ref opt_trait, _, _),
- _},
- _)) => {
- match opt_trait {
- &Some(ref t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)),
- &None => None
- }
+ match cx.impl_trait_cache.find(&id) {
+ Some(&ret) => { return ret; }
+ None => {}
+ }
+ let ret = if id.crate == ast::local_crate {
+ debug!("(impl_trait_ref) searching for trait impl %?", id);
+ match cx.items.find(&id.node) {
+ Some(&ast_map::node_item(@ast::item {
+ node: ast::item_impl(_, ref opt_trait, _, _),
+ _},
+ _)) => {
+ match opt_trait {
+ &Some(ref t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)),
+ &None => None
}
- _ => None
}
- } else {
- csearch::get_impl_trait(cx, id)
+ _ => None
}
- }
+ } else {
+ csearch::get_impl_trait(cx, id)
+ };
+ cx.impl_trait_cache.insert(id, ret);
+ return ret;
}
pub fn ty_to_def_id(ty: t) -> Option<ast::def_id> {
let tcx = ccx.tcx;
let main_t = ty::node_id_to_type(tcx, main_id);
match ty::get(main_t).sty {
- ty::ty_bare_fn(ref fn_ty) => {
+ ty::ty_bare_fn(*) => {
match tcx.items.find(&main_id) {
Some(&ast_map::node_item(it,_)) => {
match it.node {
impl protocol_ {
/// Get a state.
pub fn get_state(&self, name: &str) -> state {
- *self.states.iter().find_(|i| name == i.name).get()
+ let mut i = self.states.iter();
+ *i.find_(|i| name == i.name).get()
}
pub fn get_state_by_id(&self, id: uint) -> state { self.states[id] }