Skip to content

Commit ac3505a

Browse files
committed
---
yaml --- r: 128758 b: refs/heads/try c: 3fe0ba9 h: refs/heads/master v: v3
1 parent a318fec commit ac3505a

File tree

19 files changed

+98
-111
lines changed

19 files changed

+98
-111
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 6291781592ff079fc1e84f4b8be5684d2a52b8bd
5+
refs/heads/try: 3fe0ba9afc7504ec01a778d8d72bd0b72fd013e1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libnative/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Process {
8080
rtio::Ignored => { ret.push(None); Ok(None) }
8181
rtio::InheritFd(fd) => {
8282
ret.push(None);
83-
Ok(Some(file::FileDesc::new(fd, true)))
83+
Ok(Some(file::FileDesc::new(fd, false)))
8484
}
8585
rtio::CreatePipe(readable, _writable) => {
8686
let (reader, writer) = try!(pipe());

branches/try/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ impl<'a> GatherLoanCtxt<'a> {
261261
self.bccx, borrow_span, cause,
262262
cmt.clone(), loan_region);
263263

264-
debug!("guarantee_valid(): restrictions={:?}", restr);
265-
266264
// Create the loan record (if needed).
267265
let loan = match restr {
268266
restrictions::Safe => {

branches/try/src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ impl<'a> RestrictionsContext<'a> {
122122
}
123123

124124
mc::cat_deref(cmt_base, _, mc::BorrowedPtr(ty::ImmBorrow, lt)) |
125-
mc::cat_deref(cmt_base, _, mc::Implicit(ty::ImmBorrow, lt)) => {
125+
mc::cat_deref(cmt_base, _, mc::BorrowedPtr(ty::UniqueImmBorrow, lt)) |
126+
mc::cat_deref(cmt_base, _, mc::Implicit(ty::ImmBorrow, lt)) |
127+
mc::cat_deref(cmt_base, _, mc::Implicit(ty::UniqueImmBorrow, lt)) => {
126128
// R-Deref-Imm-Borrowed
127129
if !self.bccx.is_subregion_of(self.loan_region, lt) {
128130
self.bccx.report(
@@ -140,9 +142,7 @@ impl<'a> RestrictionsContext<'a> {
140142
mc::cat_deref(cmt_base, _, pk) => {
141143
match pk {
142144
mc::BorrowedPtr(ty::MutBorrow, lt) |
143-
mc::BorrowedPtr(ty::UniqueImmBorrow, lt) |
144-
mc::Implicit(ty::MutBorrow, lt) |
145-
mc::Implicit(ty::UniqueImmBorrow, lt) => {
145+
mc::Implicit(ty::MutBorrow, lt) => {
146146
// R-Deref-Mut-Borrowed
147147
if !self.bccx.is_subregion_of(self.loan_region, lt) {
148148
self.bccx.report(

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,10 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
399399
ast::ExprForLoop(ref pat, ref head, ref blk, _) => {
400400
// The pattern lives as long as the block.
401401
debug!("walk_expr for loop case: blk id={}", blk.id);
402-
self.consume_expr(&**head);
402+
self.walk_expr(&**head);
403403

404-
// Fetch the type of the value that the iteration yields to
405-
// produce the pattern's categorized mutable type.
406-
let pattern_type = ty::node_id_to_type(self.tcx(), pat.id);
407-
let pat_cmt = self.mc.cat_rvalue(pat.id,
408-
pat.span,
409-
ty::ReScope(blk.id),
410-
pattern_type);
411-
self.walk_pat(pat_cmt, pat.clone());
404+
let head_cmt = return_if_err!(self.mc.cat_expr(&**head));
405+
self.walk_pat(head_cmt, pat.clone());
412406

413407
self.walk_block(&**blk);
414408
}
@@ -841,7 +835,6 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
841835
}
842836
ast::PatIdent(ast::BindByValue(_), _, _) => {
843837
let mode = copy_or_move(typer.tcx(), cmt_pat.ty, PatBindingMove);
844-
debug!("walk_pat binding consuming pat");
845838
delegate.consume_pat(pat, cmt_pat, mode);
846839
}
847840
_ => {

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,8 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
13431343
output_type: ty::t,
13441344
param_substs: &'a param_substs,
13451345
sp: Option<Span>,
1346-
block_arena: &'a TypedArena<Block<'a>>)
1346+
block_arena: &'a TypedArena<Block<'a>>,
1347+
handle_items: HandleItemsFlag)
13471348
-> FunctionContext<'a> {
13481349
param_substs.validate();
13491350

@@ -1378,7 +1379,8 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
13781379
block_arena: block_arena,
13791380
ccx: ccx,
13801381
debug_context: debug_context,
1381-
scopes: RefCell::new(Vec::new())
1382+
scopes: RefCell::new(Vec::new()),
1383+
handle_items: handle_items,
13821384
};
13831385

13841386
if has_env {
@@ -1706,7 +1708,8 @@ pub fn trans_closure(ccx: &CrateContext,
17061708
abi: Abi,
17071709
has_env: bool,
17081710
is_unboxed_closure: IsUnboxedClosureFlag,
1709-
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>) {
1711+
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>,
1712+
handle_items: HandleItemsFlag) {
17101713
ccx.stats.n_closures.set(ccx.stats.n_closures.get() + 1);
17111714

17121715
let _icx = push_ctxt("trans_closure");
@@ -1723,7 +1726,8 @@ pub fn trans_closure(ccx: &CrateContext,
17231726
output_type,
17241727
param_substs,
17251728
Some(body.span),
1726-
&arena);
1729+
&arena,
1730+
handle_items);
17271731
let mut bcx = init_function(&fcx, false, output_type);
17281732

17291733
// cleanup scope for the incoming arguments
@@ -1832,7 +1836,8 @@ pub fn trans_fn(ccx: &CrateContext,
18321836
llfndecl: ValueRef,
18331837
param_substs: &param_substs,
18341838
id: ast::NodeId,
1835-
attrs: &[ast::Attribute]) {
1839+
attrs: &[ast::Attribute],
1840+
handle_items: HandleItemsFlag) {
18361841
let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_string(id).to_string());
18371842
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
18381843
let _icx = push_ctxt("trans_fn");
@@ -1852,7 +1857,8 @@ pub fn trans_fn(ccx: &CrateContext,
18521857
abi,
18531858
false,
18541859
NotUnboxedClosure,
1855-
|bcx| bcx);
1860+
|bcx| bcx,
1861+
handle_items);
18561862
}
18571863

18581864
pub fn trans_enum_variant(ccx: &CrateContext,
@@ -1958,7 +1964,7 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
19581964

19591965
let arena = TypedArena::new();
19601966
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
1961-
param_substs, None, &arena);
1967+
param_substs, None, &arena, TranslateItems);
19621968
let bcx = init_function(&fcx, false, result_ty);
19631969

19641970
assert!(!fcx.needs_ret_allocas);
@@ -2060,22 +2066,24 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
20602066
llfn,
20612067
&param_substs::empty(),
20622068
item.id,
2063-
None);
2069+
None,
2070+
TranslateItems);
20642071
} else {
20652072
trans_fn(ccx,
20662073
&**decl,
20672074
&**body,
20682075
llfn,
20692076
&param_substs::empty(),
20702077
item.id,
2071-
item.attrs.as_slice());
2078+
item.attrs.as_slice(),
2079+
TranslateItems);
20722080
}
2081+
} else {
2082+
// Be sure to travel more than just one layer deep to catch nested
2083+
// items in blocks and such.
2084+
let mut v = TransItemVisitor{ ccx: ccx };
2085+
v.visit_block(&**body, ());
20732086
}
2074-
2075-
// Be sure to travel more than just one layer deep to catch nested
2076-
// items in blocks and such.
2077-
let mut v = TransItemVisitor{ ccx: ccx };
2078-
v.visit_block(&**body, ());
20792087
}
20802088
ast::ItemImpl(ref generics, _, _, ref ms) => {
20812089
meth::trans_impl(ccx, item.ident, ms.as_slice(), generics, item.id);

branches/try/src/librustc/middle/trans/callee.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ pub fn trans_unboxing_shim(bcx: &Block,
339339
return_type,
340340
&empty_param_substs,
341341
None,
342-
&block_arena);
342+
&block_arena,
343+
TranslateItems);
343344
let mut bcx = init_function(&fcx, false, return_type);
344345

345346
// Create the substituted versions of the self type.

branches/try/src/librustc/middle/trans/closure.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ pub fn trans_expr_fn<'a>(
394394
ty::ty_fn_abi(fty),
395395
true,
396396
NotUnboxedClosure,
397-
|bcx| load_environment(bcx, cdata_ty, &freevars, store));
397+
|bcx| load_environment(bcx, cdata_ty, &freevars, store),
398+
bcx.fcx.handle_items);
398399
fill_fn_pair(bcx, dest_addr, llfn, llbox);
399400
bcx
400401
}
@@ -486,7 +487,8 @@ pub fn trans_unboxed_closure<'a>(
486487
ty::ty_fn_abi(function_type),
487488
true,
488489
IsUnboxedClosure,
489-
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr));
490+
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr),
491+
bcx.fcx.handle_items);
490492

491493
// Don't hoist this to the top of the function. It's perfectly legitimate
492494
// to have a zero-size unboxed closure (in which case dest will be
@@ -573,7 +575,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
573575
let arena = TypedArena::new();
574576
let empty_param_substs = param_substs::empty();
575577
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.output,
576-
&empty_param_substs, None, &arena);
578+
&empty_param_substs, None, &arena, TranslateItems);
577579
let bcx = init_function(&fcx, true, f.sig.output);
578580

579581
let args = create_datums_for_fn_args(&fcx,

branches/try/src/librustc/middle/trans/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ impl<T:Subst+Clone> SubstP for T {
224224
pub type RvalueDatum = datum::Datum<datum::Rvalue>;
225225
pub type LvalueDatum = datum::Datum<datum::Lvalue>;
226226

227+
#[deriving(Clone, Eq, PartialEq)]
228+
pub enum HandleItemsFlag {
229+
IgnoreItems,
230+
TranslateItems,
231+
}
232+
227233
// Function context. Every LLVM function we create will have one of
228234
// these.
229235
pub struct FunctionContext<'a> {
@@ -297,6 +303,9 @@ pub struct FunctionContext<'a> {
297303

298304
// Cleanup scopes.
299305
pub scopes: RefCell<Vec<cleanup::CleanupScope<'a>> >,
306+
307+
// How to handle items encountered during translation of this function.
308+
pub handle_items: HandleItemsFlag,
300309
}
301310

302311
impl<'a> FunctionContext<'a> {

branches/try/src/librustc/middle/trans/controlflow.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
6969
debuginfo::create_local_var_metadata(bcx, &**local);
7070
}
7171
}
72-
// Inner items are visited by `trans_item`/`trans_meth`.
73-
ast::DeclItem(_) => {},
72+
ast::DeclItem(ref i) => {
73+
match fcx.handle_items {
74+
TranslateItems => trans_item(cx.fcx.ccx, &**i),
75+
IgnoreItems => {}
76+
}
77+
}
7478
}
7579
}
7680
ast::StmtMac(..) => cx.tcx().sess.bug("unexpanded macro")

branches/try/src/librustc/middle/trans/foreign.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
577577
llwrapfn: ValueRef,
578578
param_substs: &param_substs,
579579
id: ast::NodeId,
580-
hash: Option<&str>) {
580+
hash: Option<&str>,
581+
handle_items: HandleItemsFlag) {
581582
let _icx = push_ctxt("foreign::build_foreign_fn");
582583

583584
let fnty = ty::node_id_to_type(ccx.tcx(), id);
@@ -586,7 +587,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
586587

587588
unsafe { // unsafe because we call LLVM operations
588589
// Build up the Rust function (`foo0` above).
589-
let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id, hash);
590+
let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id,
591+
hash, handle_items);
590592

591593
// Build up the foreign wrapper (`foo` above).
592594
return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys, mty);
@@ -598,7 +600,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
598600
param_substs: &param_substs,
599601
attrs: &[ast::Attribute],
600602
id: ast::NodeId,
601-
hash: Option<&str>)
603+
hash: Option<&str>,
604+
handle_items: HandleItemsFlag)
602605
-> ValueRef {
603606
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
604607
let tcx = ccx.tcx();
@@ -630,7 +633,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
630633

631634
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
632635
base::set_llvm_fn_attrs(attrs, llfn);
633-
base::trans_fn(ccx, decl, body, llfn, param_substs, id, []);
636+
base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], handle_items);
634637
llfn
635638
}
636639

branches/try/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn make_generic_glue(ccx: &CrateContext,
468468
let arena = TypedArena::new();
469469
let empty_param_substs = param_substs::empty();
470470
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false, ty::mk_nil(),
471-
&empty_param_substs, None, &arena);
471+
&empty_param_substs, None, &arena, TranslateItems);
472472

473473
let bcx = init_function(&fcx, false, ty::mk_nil());
474474

branches/try/src/librustc/middle/trans/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
133133
if unparameterized {
134134
let llfn = get_item_val(ccx, mth.id);
135135
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), llfn,
136-
&param_substs::empty(), mth.id, []);
136+
&param_substs::empty(), mth.id, [], TranslateItems);
137137
}
138138
local_def(mth.id)
139139
}

branches/try/src/librustc/middle/trans/meth.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ pub fn trans_impl(ccx: &CrateContext,
7575
llfn,
7676
&param_substs::empty(),
7777
method.id,
78-
[]);
78+
[],
79+
TranslateItems);
80+
} else {
81+
let mut v = TransItemVisitor{ ccx: ccx };
82+
visit::walk_method_helper(&mut v, &**method, ());
7983
}
80-
let mut v = TransItemVisitor{ ccx: ccx };
81-
visit::walk_method_helper(&mut v, &**method, ());
8284
}
8385
}
8486

branches/try/src/librustc/middle/trans/monomorphize.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ pub fn monomorphic_fn(ccx: &CrateContext,
164164
if abi != abi::Rust {
165165
foreign::trans_rust_fn_with_foreign_abi(
166166
ccx, &**decl, &**body, [], d, &psubsts, fn_id.node,
167-
Some(hash.as_slice()));
167+
Some(hash.as_slice()), IgnoreItems);
168168
} else {
169-
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, []);
169+
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, [],
170+
IgnoreItems);
170171
}
171172

172173
d
@@ -200,7 +201,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
200201
ast_map::NodeMethod(mth) => {
201202
let d = mk_lldecl(abi::Rust);
202203
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
203-
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, []);
204+
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, [],
205+
IgnoreItems);
204206
d
205207
}
206208
ast_map::NodeTraitMethod(method) => {
@@ -209,7 +211,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
209211
let d = mk_lldecl(abi::Rust);
210212
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
211213
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d,
212-
&psubsts, mth.id, []);
214+
&psubsts, mth.id, [], IgnoreItems);
213215
d
214216
}
215217
_ => {

branches/try/src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
312312
let empty_param_substs = param_substs::empty();
313313
let fcx = new_fn_ctxt(ccx, llfdecl, ast::DUMMY_NODE_ID, false,
314314
ty::mk_u64(), &empty_param_substs,
315-
None, &arena);
315+
None, &arena, TranslateItems);
316316
let bcx = init_function(&fcx, false, ty::mk_u64());
317317

318318
// we know the return type of llfdecl is an int here, so

0 commit comments

Comments
 (0)