Skip to content

Commit 3f62f9b

Browse files
committed
ty: several small fixes to is_instantiable
* Don't return early, so logging is not skipped * Remove one allocation * Indent the match statement correctly
1 parent 278b3be commit 3f62f9b

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

src/librustc/middle/ty.rs

+49-49
Original file line numberDiff line numberDiff line change
@@ -2316,59 +2316,59 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
23162316
::util::ppaux::ty_to_str(cx, ty));
23172317

23182318
let r = match get(ty).sty {
2319-
ty_nil |
2320-
ty_bot |
2321-
ty_bool |
2322-
ty_int(_) |
2323-
ty_uint(_) |
2324-
ty_float(_) |
2325-
ty_estr(_) |
2326-
ty_bare_fn(_) |
2327-
ty_closure(_) |
2328-
ty_infer(_) |
2329-
ty_err |
2330-
ty_param(_) |
2331-
ty_self(_) |
2332-
ty_type |
2333-
ty_opaque_box |
2334-
ty_opaque_closure_ptr(_) |
2335-
ty_evec(_, _) |
2336-
ty_unboxed_vec(_) => {
2337-
false
2338-
}
2339-
ty_box(ref mt) |
2340-
ty_uniq(ref mt) |
2341-
ty_rptr(_, ref mt) => {
2342-
return type_requires(cx, seen, r_ty, mt.ty);
2343-
}
2319+
ty_nil |
2320+
ty_bot |
2321+
ty_bool |
2322+
ty_int(_) |
2323+
ty_uint(_) |
2324+
ty_float(_) |
2325+
ty_estr(_) |
2326+
ty_bare_fn(_) |
2327+
ty_closure(_) |
2328+
ty_infer(_) |
2329+
ty_err |
2330+
ty_param(_) |
2331+
ty_self(_) |
2332+
ty_type |
2333+
ty_opaque_box |
2334+
ty_opaque_closure_ptr(_) |
2335+
ty_evec(_, _) |
2336+
ty_unboxed_vec(_) => {
2337+
false
2338+
}
2339+
ty_box(ref mt) |
2340+
ty_uniq(ref mt) |
2341+
ty_rptr(_, ref mt) => {
2342+
type_requires(cx, seen, r_ty, mt.ty)
2343+
}
23442344

2345-
ty_ptr(*) => {
2346-
false // unsafe ptrs can always be NULL
2347-
}
2345+
ty_ptr(*) => {
2346+
false // unsafe ptrs can always be NULL
2347+
}
23482348

2349-
ty_trait(_, _, _, _) => {
2350-
false
2351-
}
2349+
ty_trait(_, _, _, _) => {
2350+
false
2351+
}
23522352

2353-
ty_struct(ref did, _) if vec::contains(*seen, did) => {
2354-
false
2355-
}
2353+
ty_struct(ref did, _) if vec::contains(*seen, did) => {
2354+
false
2355+
}
23562356

2357-
ty_struct(did, ref substs) => {
2358-
seen.push(did);
2359-
let fields = struct_fields(cx, did, substs);
2360-
let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
2361-
seen.pop();
2362-
r
2363-
}
2357+
ty_struct(did, ref substs) => {
2358+
seen.push(did);
2359+
let fields = struct_fields(cx, did, substs);
2360+
let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
2361+
seen.pop();
2362+
r
2363+
}
23642364

2365-
ty_tup(ref ts) => {
2366-
ts.any(|t| type_requires(cx, seen, r_ty, *t))
2367-
}
2365+
ty_tup(ref ts) => {
2366+
ts.any(|t| type_requires(cx, seen, r_ty, *t))
2367+
}
23682368

2369-
ty_enum(ref did, _) if vec::contains(*seen, did) => {
2370-
false
2371-
}
2369+
ty_enum(ref did, _) if vec::contains(*seen, did) => {
2370+
false
2371+
}
23722372

23732373
ty_enum(did, ref substs) => {
23742374
seen.push(did);
@@ -2392,8 +2392,8 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
23922392
return r;
23932393
}
23942394

2395-
let seen = @mut ~[];
2396-
!subtypes_require(cx, seen, r_ty, r_ty)
2395+
let mut seen = ~[];
2396+
!subtypes_require(cx, &mut seen, r_ty, r_ty)
23972397
}
23982398

23992399
pub fn type_structurally_contains(cx: ctxt,

0 commit comments

Comments
 (0)