]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/attributes.rs
Split TyBareFn into TyFnDef and TyFnPtr.
[rust.git] / src / librustc_trans / trans / attributes.rs
index af4c2205e659b8067b981c67ff040b01b5921622..d6dc7d45d2b8c3e95de363db6c884f52a6e932a8 100644 (file)
@@ -14,7 +14,7 @@
 use middle::ty;
 use middle::infer;
 use session::config::NoDebugInfo;
-use syntax::abi;
+use syntax::abi::Abi;
 pub use syntax::attr::InlineAttr;
 use syntax::ast;
 use rustc_front::hir;
@@ -131,17 +131,18 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
 
     let function_type;
     let (fn_sig, abi, env_ty) = match fn_type.sty {
-        ty::TyBareFn(_, ref f) => (&f.sig, f.abi, None),
+        ty::TyFnDef(_, ref f) | ty::TyFnPtr(ref f) => (&f.sig, f.abi, None),
         ty::TyClosure(closure_did, ref substs) => {
             let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables);
             function_type = infcx.closure_type(closure_did, substs);
             let self_type = base::self_type_for_closure(ccx, closure_did, fn_type);
-            (&function_type.sig, abi::RustCall, Some(self_type))
+            (&function_type.sig, Abi::RustCall, Some(self_type))
         }
         _ => ccx.sess().bug("expected closure or function.")
     };
 
     let fn_sig = ccx.tcx().erase_late_bound_regions(fn_sig);
+    let fn_sig = infer::normalize_associated_type(ccx.tcx(), &fn_sig);
 
     let mut attrs = llvm::AttrBuilder::new();
     let ret_ty = fn_sig.output;
@@ -150,23 +151,23 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
     // unpack the input ty's
     let input_tys = match fn_type.sty {
         ty::TyClosure(..) => {
-            assert!(abi == abi::RustCall);
+            assert!(abi == Abi::RustCall);
 
             match fn_sig.inputs[0].sty {
                 ty::TyTuple(ref inputs) => {
                     let mut full_inputs = vec![env_ty.expect("Missing closure environment")];
-                    full_inputs.push_all(inputs);
+                    full_inputs.extend_from_slice(inputs);
                     full_inputs
                 }
                 _ => ccx.sess().bug("expected tuple'd inputs")
             }
         },
-        ty::TyBareFn(..) if abi == abi::RustCall => {
+        ty::TyFnDef(..) | ty::TyFnPtr(_) if abi == Abi::RustCall => {
             let mut inputs = vec![fn_sig.inputs[0]];
 
             match fn_sig.inputs[1].sty {
                 ty::TyTuple(ref t_in) => {
-                    inputs.push_all(&t_in[..]);
+                    inputs.extend_from_slice(&t_in[..]);
                     inputs
                 }
                 _ => ccx.sess().bug("expected tuple'd inputs")
@@ -264,7 +265,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
                 // on memory dependencies rather than pointer equality
                 let interior_unsafe = mt.ty.type_contents(ccx.tcx()).interior_unsafe();
 
-                if mt.mutbl == hir::MutMutable || !interior_unsafe {
+                if mt.mutbl != hir::MutMutable && !interior_unsafe {
                     attrs.arg(idx, llvm::Attribute::NoAlias);
                 }