]> git.lizzy.rs Git - rust.git/commitdiff
Fix inconsistent use of substs in trans_unboxing_shim
authorBrian Koropoff <bkoropoff@gmail.com>
Wed, 12 Nov 2014 05:24:36 +0000 (21:24 -0800)
committerBrian Koropoff <bkoropoff@gmail.com>
Wed, 12 Nov 2014 05:24:36 +0000 (21:24 -0800)
Substs were not applied when calling `untuple_arguments_if_necessary`.
Just apply them once at the start of the function, rebinding `fty`.
Also change the function to take them by reference since we don't
need to consume them at all.  Closes #18883

src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/meth.rs

index 987866ed243e53ca7942b0aecd89642bd2c5fee5..7a040196ea87bb342f339267e164cd0fbd749170 100644 (file)
@@ -253,12 +253,14 @@ pub fn trans_unboxing_shim(bcx: Block,
                            llshimmedfn: ValueRef,
                            fty: &ty::BareFnTy,
                            method_id: ast::DefId,
-                           substs: subst::Substs)
+                           substs: &subst::Substs)
                            -> ValueRef {
     let _icx = push_ctxt("trans_unboxing_shim");
     let ccx = bcx.ccx();
     let tcx = bcx.tcx();
 
+    let fty = fty.subst(tcx, substs);
+
     // Transform the self type to `Box<self_type>`.
     let self_type = fty.sig.inputs[0];
     let boxed_self_type = ty::mk_uniq(tcx, self_type);
@@ -279,8 +281,7 @@ pub fn trans_unboxing_shim(bcx: Block,
         abi: fty.abi,
         sig: boxed_function_type,
     };
-    let boxed_function_type =
-        ty::mk_bare_fn(tcx, boxed_function_type).subst(tcx, &substs);
+    let boxed_function_type = ty::mk_bare_fn(tcx, boxed_function_type);
     let function_type = match fty.abi {
         synabi::RustCall => {
             // We're passing through to a RustCall ABI function, but
@@ -301,10 +302,10 @@ pub fn trans_unboxing_shim(bcx: Block,
                 abi: synabi::Rust,
                 sig: fake_ty,
             };
-            ty::mk_bare_fn(tcx, fake_ty).subst(tcx, &substs)
+            ty::mk_bare_fn(tcx, fake_ty)
         }
         _ => {
-            ty::mk_bare_fn(tcx, (*fty).clone()).subst(tcx, &substs)
+            ty::mk_bare_fn(tcx, fty)
         }
     };
 
index 4ddba0ee83944298f43c82c1a3f270efaff85ba7..098b82fe38c181e8a16d34496898b3c45546567f 100644 (file)
@@ -624,7 +624,7 @@ pub fn get_vtable(bcx: Block,
                                                    llfn,
                                                    &closure_type,
                                                    closure_def_id,
-                                                   substs);
+                                                   &substs);
                     }
                 }
 
@@ -723,7 +723,7 @@ fn emit_vtable_methods(bcx: Block,
                                                      fn_ref,
                                                      &m.fty,
                                                      m_id,
-                                                     substs.clone());
+                                                     &substs);
                     }
                     Some(fn_ref).into_iter()
                 }