Skip to content

Commit e3c8994

Browse files
Forward attributes of translated function/closure to trans_fn/trans_closure.
1 parent a06bb97 commit e3c8994

File tree

7 files changed

+42
-13
lines changed

7 files changed

+42
-13
lines changed

src/librustc_trans/trans/closure.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use session::config::FullDebugInfo;
3131

3232
use syntax::abi::RustCall;
3333
use syntax::ast;
34+
use syntax::attr::{ThinAttributes, ThinAttributesExt};
3435

3536
use rustc_front::hir;
3637

@@ -176,7 +177,8 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
176177
body: &hir::Block,
177178
id: ast::NodeId,
178179
closure_def_id: DefId, // (*)
179-
closure_substs: &'tcx ty::ClosureSubsts<'tcx>)
180+
closure_substs: &'tcx ty::ClosureSubsts<'tcx>,
181+
closure_expr_attrs: &ThinAttributes)
180182
-> Option<Block<'a, 'tcx>>
181183
{
182184
// (*) 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>,
218220
llfn,
219221
param_substs,
220222
id,
221-
&[],
223+
closure_expr_attrs.as_attr_slice(),
222224
sig.output,
223225
function_type.abi,
224226
ClosureEnv::Closure(closure_def_id, &freevars));

src/librustc_trans/trans/consts.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
10191019
hir::ExprClosure(_, ref decl, ref body) => {
10201020
match ety.sty {
10211021
ty::TyClosure(def_id, ref substs) => {
1022-
closure::trans_closure_expr(closure::Dest::Ignore(cx), decl,
1023-
body, e.id, def_id, substs);
1022+
closure::trans_closure_expr(closure::Dest::Ignore(cx),
1023+
decl,
1024+
body,
1025+
e.id,
1026+
def_id,
1027+
substs,
1028+
&e.attrs);
10241029
}
10251030
_ =>
10261031
cx.sess().span_bug(

src/librustc_trans/trans/expr.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,13 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11961196
&format!("closure expr without closure type: {:?}", t)),
11971197
};
11981198

1199-
closure::trans_closure_expr(dest, decl, body, expr.id, def_id, substs).unwrap_or(bcx)
1199+
closure::trans_closure_expr(dest,
1200+
decl,
1201+
body,
1202+
expr.id,
1203+
def_id,
1204+
substs,
1205+
&expr.attrs).unwrap_or(bcx)
12001206
}
12011207
hir::ExprCall(ref f, ref args) => {
12021208
if bcx.tcx().is_method_call(expr.id) {

src/librustc_trans/trans/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
639639

640640
let llfn = declare::define_internal_rust_fn(ccx, &ps, t);
641641
attributes::from_fn_attrs(ccx, attrs, llfn);
642-
base::trans_fn(ccx, decl, body, llfn, param_substs, id, &[]);
642+
base::trans_fn(ccx, decl, body, llfn, param_substs, id, attrs);
643643
llfn
644644
}
645645

src/librustc_trans/trans/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
165165
llfn,
166166
empty_substs,
167167
impl_item.id,
168-
&[]);
168+
&impl_item.attrs);
169169
// See linkage comments on items.
170170
if ccx.sess().opts.cg.codegen_units == 1 {
171171
SetLinkage(llfn, InternalLinkage);

src/librustc_trans/trans/meth.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ pub fn trans_impl(ccx: &CrateContext,
7474
for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
7575
let llfn = get_item_val(ccx, impl_item.id);
7676
let empty_substs = tcx.mk_substs(Substs::trans_empty());
77-
trans_fn(ccx, &sig.decl, body, llfn,
78-
empty_substs, impl_item.id, &[]);
77+
trans_fn(ccx,
78+
&sig.decl,
79+
body,
80+
llfn,
81+
empty_substs,
82+
impl_item.id,
83+
&impl_item.attrs);
7984
update_linkage(ccx,
8085
llfn,
8186
Some(impl_item.id),

src/librustc_trans/trans/monomorphize.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
185185
ccx, &**decl, &**body, &[], d, psubsts, fn_node_id,
186186
Some(&hash[..]));
187187
} else {
188-
trans_fn(ccx, &**decl, &**body, d, psubsts, fn_node_id, &[]);
188+
trans_fn(ccx,
189+
&**decl,
190+
&**body,
191+
d,
192+
psubsts,
193+
fn_node_id,
194+
&i.attrs);
189195
}
190196
}
191197

@@ -216,7 +222,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
216222
d,
217223
psubsts,
218224
impl_item.id,
219-
&[]);
225+
&impl_item.attrs);
220226
}
221227
d
222228
}
@@ -232,8 +238,13 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
232238
let d = mk_lldecl(abi::Rust);
233239
let needs_body = setup_lldecl(d, &trait_item.attrs);
234240
if needs_body {
235-
trans_fn(ccx, &sig.decl, body, d,
236-
psubsts, trait_item.id, &[]);
241+
trans_fn(ccx,
242+
&sig.decl,
243+
body,
244+
d,
245+
psubsts,
246+
trait_item.id,
247+
&trait_item.attrs);
237248
}
238249
d
239250
}

0 commit comments

Comments
 (0)