match tcx.named_region_map.find(¶m_id) {
Some(&rl::DefEarlyBoundRegion(_, _, lifetime_decl_id))
=> lifetime_decl_id,
- Some(_) => fail!("should not encounter non early-bound cases"),
+ Some(_) => panic!("should not encounter non early-bound cases"),
// The lookup should only fail when `param_id` is
// itself a lifetime binding: use it as the decl_id.
assert!(is_lifetime(&tcx.map, param_id));
let parent_id = tcx.map.get_parent(decl_id);
let parent = tcx.map.find(parent_id).unwrap_or_else(
- || fail!("tcx.map missing entry for id: {}", parent_id));
+ || panic!("tcx.map missing entry for id: {}", parent_id));
let is_inferred;
macro_rules! cannot_happen { () => { {
- fail!("invalid parent: {:s} for {:s}",
+ panic!("invalid parent: {:s} for {:s}",
tcx.map.node_to_string(parent_id),
tcx.map.node_to_string(param_id));
} } }
// variance not yet inferred, so return a symbolic
// variance.
let InferredIndex(index) = self.inferred_index(param_def_id.node);
- self.terms_cx.inferred_infos.get(index).term
+ self.terms_cx.inferred_infos[index].term
} else {
// Parameter on an item defined within another crate:
// variance already inferred, just look it up.
}
_ => {
- self.terms_cx.arena.alloc(|| TransformTerm(v1, v2))
+ &*self.terms_cx.arena.alloc(|| TransformTerm(v1, v2))
}
}
}
debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
match ty::get(ty).sty {
- ty::ty_nil | ty::ty_bot | ty::ty_bool |
+ ty::ty_nil | ty::ty_bool |
ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
ty::ty_float(_) | ty::ty_str => {
/* leaf type -- noop */
}
- ty::ty_unboxed_closure(_, region) => {
- let contra = self.contravariant(variance);
- self.add_constraints_from_region(region, contra);
+ ty::ty_unboxed_closure(..) => {
+ self.tcx().sess.bug("Unexpected unboxed closure type in variance computation");
}
ty::ty_rptr(region, ref mt) => {
variance);
}
- ty::ty_param(ty::ParamTy { def_id: ref def_id, .. }) => {
+ ty::ty_param(ty::ParamTy { ref def_id, .. }) => {
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
match self.terms_cx.inferred_map.find(&def_id.node) {
Some(&index) => {
for &input in sig.inputs.iter() {
self.add_constraints_from_ty(input, contra);
}
- self.add_constraints_from_ty(sig.output, variance);
+ if let ty::FnConverging(result_type) = sig.output {
+ self.add_constraints_from_ty(result_type, variance);
+ }
}
/// Adds constraints appropriate for a region appearing in a
let Constraint { inferred, variance: term } = *constraint;
let InferredIndex(inferred) = inferred;
let variance = self.evaluate(term);
- let old_value = *self.solutions.get(inferred);
+ let old_value = self.solutions[inferred];
let new_value = glb(variance, old_value);
if old_value != new_value {
debug!("Updating inferred {} (node {}) \
from {} to {} due to {}",
inferred,
self.terms_cx
- .inferred_infos
- .get(inferred)
+ .inferred_infos[inferred]
.param_id,
old_value,
new_value,
let mut index = 0;
let num_inferred = self.terms_cx.num_inferred();
while index < num_inferred {
- let item_id = inferred_infos.get(index).item_id;
+ let item_id = inferred_infos[index].item_id;
let mut types = VecPerParamSpace::empty();
let mut regions = VecPerParamSpace::empty();
while index < num_inferred &&
- inferred_infos.get(index).item_id == item_id {
- let info = inferred_infos.get(index);
- let variance = *solutions.get(index);
+ inferred_infos[index].item_id == item_id {
+ let info = inferred_infos[index];
+ let variance = solutions[index];
debug!("Index {} Info {} / {} / {} Variance {}",
index, info.index, info.kind, info.space, variance);
match info.kind {
}
InferredTerm(InferredIndex(index)) => {
- *self.solutions.get(index)
+ self.solutions[index]
}
}
}