From 1070cc0109661d9f47a6e2c39ad853041ddf30e2 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 5 Jan 2013 18:41:22 -0800 Subject: [PATCH] librustc: Fix unconditional ty_to_str call in ty.rs. Was heaviest path in allocation. Negligible perf win. rs=perf-fix --- src/librustc/middle/ty.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index abeea65b01f..2ee0f9a3c2d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1606,11 +1606,18 @@ fn subst(cx: ctxt, fold_regions_and_ty( cx, typ, |r| match r { - re_bound(br_self) => substs.self_r.expect( - fmt!("ty::subst: \ - Reference to self region when given substs with no \ - self region, ty = %s", - ::util::ppaux::ty_to_str(cx, typ))), + re_bound(br_self) => { + match substs.self_r { + None => { + cx.sess.bug( + fmt!("ty::subst: \ + Reference to self region when given substs \ + with no self region, ty = %s", + ::util::ppaux::ty_to_str(cx, typ))) + } + Some(self_r) => self_r + } + } _ => r }, |t| do_subst(cx, substs, t),