]> git.lizzy.rs Git - rust.git/commitdiff
Forward attributes of translated function/closure to trans_fn/trans_closure.
authorMichael Woerister <michaelwoerister@posteo.net>
Thu, 31 Dec 2015 13:06:23 +0000 (08:06 -0500)
committerMichael Woerister <michaelwoerister@posteo.net>
Thu, 31 Dec 2015 13:06:23 +0000 (08:06 -0500)
src/librustc_trans/trans/closure.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/inline.rs
src/librustc_trans/trans/meth.rs
src/librustc_trans/trans/monomorphize.rs

index e089a6e059ccd38edc09b4bd0c3a9ef530239de7..ea9ca8f37b173ee1f7e31a4309bc258701c4a7ac 100644 (file)
@@ -31,6 +31,7 @@
 
 use syntax::abi::RustCall;
 use syntax::ast;
+use syntax::attr::{ThinAttributes, ThinAttributesExt};
 
 use rustc_front::hir;
 
@@ -176,7 +177,8 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
                                     body: &hir::Block,
                                     id: ast::NodeId,
                                     closure_def_id: DefId, // (*)
-                                    closure_substs: &'tcx ty::ClosureSubsts<'tcx>)
+                                    closure_substs: &'tcx ty::ClosureSubsts<'tcx>,
+                                    closure_expr_attrs: &ThinAttributes)
                                     -> Option<Block<'a, 'tcx>>
 {
     // (*) Note that in the case of inlined functions, the `closure_def_id` will be the
@@ -218,7 +220,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
                   llfn,
                   param_substs,
                   id,
-                  &[],
+                  closure_expr_attrs.as_attr_slice(),
                   sig.output,
                   function_type.abi,
                   ClosureEnv::Closure(closure_def_id, &freevars));
index 0fafe08178a273a725b3752e5982baacc519adba..e25819f77a172271ae957f131b8d9f7e0b5580e0 100644 (file)
@@ -1019,8 +1019,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         hir::ExprClosure(_, ref decl, ref body) => {
             match ety.sty {
                 ty::TyClosure(def_id, ref substs) => {
-                    closure::trans_closure_expr(closure::Dest::Ignore(cx), decl,
-                                                body, e.id, def_id, substs);
+                    closure::trans_closure_expr(closure::Dest::Ignore(cx),
+                                                decl,
+                                                body,
+                                                e.id,
+                                                def_id,
+                                                substs,
+                                                &e.attrs);
                 }
                 _ =>
                     cx.sess().span_bug(
index 85d4876d160be491fbe79552d86bad56645a7a3b..fb6f2190207ee3c8e33efe303b558371152800ba 100644 (file)
@@ -1196,7 +1196,13 @@ fn make_field(field_name: &str, expr: P<hir::Expr>) -> hir::Field {
                         &format!("closure expr without closure type: {:?}", t)),
             };
 
-            closure::trans_closure_expr(dest, decl, body, expr.id, def_id, substs).unwrap_or(bcx)
+            closure::trans_closure_expr(dest,
+                                        decl,
+                                        body,
+                                        expr.id,
+                                        def_id,
+                                        substs,
+                                        &expr.attrs).unwrap_or(bcx)
         }
         hir::ExprCall(ref f, ref args) => {
             if bcx.tcx().is_method_call(expr.id) {
index 9012ecaa2134fe5cde58e5e2dc7edc5fc4b55c6c..9673daf0b791789ace98e3768c6337395ec7cdd9 100644 (file)
@@ -639,7 +639,7 @@ fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
         let llfn = declare::define_internal_rust_fn(ccx, &ps, t);
         attributes::from_fn_attrs(ccx, attrs, llfn);
-        base::trans_fn(ccx, decl, body, llfn, param_substs, id, &[]);
+        base::trans_fn(ccx, decl, body, llfn, param_substs, id, attrs);
         llfn
     }
 
index 29965755eac76c76cd7dd6257f14c154de96e7c8..5968daf349f08dfcc70e571b5a28961d5a6f9854 100644 (file)
@@ -165,7 +165,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
                              llfn,
                              empty_substs,
                              impl_item.id,
-                             &[]);
+                             &impl_item.attrs);
                     // See linkage comments on items.
                     if ccx.sess().opts.cg.codegen_units == 1 {
                         SetLinkage(llfn, InternalLinkage);
index d29ab2ee6fbf62383e11f92439e68ce98e89fc53..7a1cbf206074ddf123be9f0d88268dee7c9fe158 100644 (file)
@@ -74,8 +74,13 @@ pub fn trans_impl(ccx: &CrateContext,
                     for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
                         let llfn = get_item_val(ccx, impl_item.id);
                         let empty_substs = tcx.mk_substs(Substs::trans_empty());
-                        trans_fn(ccx, &sig.decl, body, llfn,
-                                 empty_substs, impl_item.id, &[]);
+                        trans_fn(ccx,
+                                 &sig.decl,
+                                 body,
+                                 llfn,
+                                 empty_substs,
+                                 impl_item.id,
+                                 &impl_item.attrs);
                         update_linkage(ccx,
                                        llfn,
                                        Some(impl_item.id),
index 4b6a0d1a5096541cd77ba4349c0db612c417bc91..80a86bac26b9afc892044161f19400fff48d8a83 100644 (file)
@@ -185,7 +185,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                               ccx, &**decl, &**body, &[], d, psubsts, fn_node_id,
                               Some(&hash[..]));
                       } else {
-                          trans_fn(ccx, &**decl, &**body, d, psubsts, fn_node_id, &[]);
+                          trans_fn(ccx,
+                                   &**decl,
+                                   &**body,
+                                   d,
+                                   psubsts,
+                                   fn_node_id,
+                                   &i.attrs);
                       }
                   }
 
@@ -216,7 +222,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                  d,
                                  psubsts,
                                  impl_item.id,
-                                 &[]);
+                                 &impl_item.attrs);
                     }
                     d
                 }
@@ -232,8 +238,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     let d = mk_lldecl(abi::Rust);
                     let needs_body = setup_lldecl(d, &trait_item.attrs);
                     if needs_body {
-                        trans_fn(ccx, &sig.decl, body, d,
-                                 psubsts, trait_item.id, &[]);
+                        trans_fn(ccx,
+                                 &sig.decl,
+                                 body,
+                                 d,
+                                 psubsts,
+                                 trait_item.id,
+                                 &trait_item.attrs);
                     }
                     d
                 }