Use type_contains_vars in occurs_check_fails to avoid doing
any work most of the time. This fixes a performance regression.
(No one else noticed yet that typechecking just got 4x slower, right?
Well, now it isn't anymore. :-})
fn occurs_check_fails(tcx: &ctxt, sp: &option::t[span], vid: int, rt: &t)
-> bool {
+ if (!type_contains_vars(tcx, rt)) {
+ // Fast path
+ ret false;
+ }
// Occurs check!
if ivec::member(vid, vars_in_type(tcx, rt)) {
alt sp {
none. { *unresolved = some(vid); ret ty::mk_var(tcx, vid); }
some(rt) {
if occurs_check_fails(tcx, sp, vid, rt) {
- // Return the type unchanged, so we can error out downstream
+ // Return the type unchanged, so we can error out downstream
ret rt;
}
ret fold_ty(tcx,