Skip to content

Commit 86bde93

Browse files
committed
accommodate new scoping rules in rustc and rustdoc source.
1 parent 1c87af2 commit 86bde93

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

src/librustc/middle/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
809809
let scope_id = same_regions[0].scope_id;
810810
let parent = self.tcx.map.get_parent(scope_id);
811811
let parent_node = self.tcx.map.find(parent);
812+
let taken = lifetimes_in_scope(self.tcx, scope_id);
813+
let life_giver = LifeGiver::with_taken(&taken[]);
812814
let node_inner = match parent_node {
813815
Some(ref node) => match *node {
814816
ast_map::NodeItem(ref item) => {
@@ -851,8 +853,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
851853
};
852854
let (fn_decl, generics, unsafety, ident, expl_self, span)
853855
= node_inner.expect("expect item fn");
854-
let taken = lifetimes_in_scope(self.tcx, scope_id);
855-
let life_giver = LifeGiver::with_taken(&taken[]);
856856
let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
857857
generics, same_regions, &life_giver);
858858
let (fn_decl, expl_self, generics) = rebuilder.rebuild();

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub fn compile_input(sess: Session,
100100
&id[]));
101101

102102
let mut forest = ast_map::Forest::new(expanded_crate);
103+
let arenas = ty::CtxtArenas::new();
103104
let ast_map = assign_node_ids_and_map(&sess, &mut forest);
104105

105106
write_out_deps(&sess, input, &outputs, &id[]);
@@ -111,7 +112,6 @@ pub fn compile_input(sess: Session,
111112
&ast_map,
112113
&id[]));
113114

114-
let arenas = ty::CtxtArenas::new();
115115
let analysis = phase_3_run_analysis_passes(sess,
116116
ast_map,
117117
&arenas,

src/librustc_trans/trans/base.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,15 +1784,16 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
17841784
debug!("trans_closure(..., param_substs={})",
17851785
param_substs.repr(ccx.tcx()));
17861786

1787-
let arena = TypedArena::new();
1788-
let fcx = new_fn_ctxt(ccx,
1789-
llfndecl,
1790-
fn_ast_id,
1791-
closure_env.kind != closure::NotClosure,
1792-
output_type,
1793-
param_substs,
1794-
Some(body.span),
1795-
&arena);
1787+
let (arena, fcx): (TypedArena<_>, FunctionContext);
1788+
arena = TypedArena::new();
1789+
fcx = new_fn_ctxt(ccx,
1790+
llfndecl,
1791+
fn_ast_id,
1792+
closure_env.kind != closure::NotClosure,
1793+
output_type,
1794+
param_substs,
1795+
Some(body.span),
1796+
&arena);
17961797
let mut bcx = init_function(&fcx, false, output_type);
17971798

17981799
// cleanup scope for the incoming arguments
@@ -2046,9 +2047,10 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
20462047
ty_to_string(ccx.tcx(), ctor_ty))[])
20472048
};
20482049

2049-
let arena = TypedArena::new();
2050-
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
2051-
param_substs, None, &arena);
2050+
let (arena, fcx): (TypedArena<_>, FunctionContext);
2051+
arena = TypedArena::new();
2052+
fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
2053+
param_substs, None, &arena);
20522054
let bcx = init_function(&fcx, false, result_ty);
20532055

20542056
assert!(!fcx.needs_ret_allocas);

src/librustc_trans/trans/callee.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,17 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
322322
&function_name[]);
323323

324324
//
325-
let block_arena = TypedArena::new();
326325
let empty_substs = Substs::trans_empty();
327-
let fcx = new_fn_ctxt(ccx,
328-
llfn,
329-
ast::DUMMY_NODE_ID,
330-
false,
331-
sig.output,
332-
&empty_substs,
333-
None,
334-
&block_arena);
326+
let (block_arena, fcx): (TypedArena<_>, FunctionContext);
327+
block_arena = TypedArena::new();
328+
fcx = new_fn_ctxt(ccx,
329+
llfn,
330+
ast::DUMMY_NODE_ID,
331+
false,
332+
sig.output,
333+
&empty_substs,
334+
None,
335+
&block_arena);
335336
let mut bcx = init_function(&fcx, false, sig.output);
336337

337338
// the first argument (`self`) will be ptr to the the fn pointer

src/librustc_trans/trans/glue.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,12 @@ fn make_generic_glue<'a, 'tcx, F>(ccx: &CrateContext<'a, 'tcx>,
540540
let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
541541
let _s = StatRecorder::new(ccx, glue_name);
542542

543-
let arena = TypedArena::new();
544543
let empty_param_substs = Substs::trans_empty();
545-
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false,
546-
ty::FnConverging(ty::mk_nil(ccx.tcx())),
547-
&empty_param_substs, None, &arena);
544+
let (arena, fcx): (TypedArena<_>, FunctionContext);
545+
arena = TypedArena::new();
546+
fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false,
547+
ty::FnConverging(ty::mk_nil(ccx.tcx())),
548+
&empty_param_substs, None, &arena);
548549

549550
let bcx = init_function(&fcx, false, ty::FnConverging(ty::mk_nil(ccx.tcx())));
550551

src/librustc_trans/trans/meth.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,17 @@ pub fn trans_object_shim<'a, 'tcx>(
601601

602602
let sig = ty::erase_late_bound_regions(ccx.tcx(), &fty.sig);
603603

604-
//
605-
let block_arena = TypedArena::new();
606604
let empty_substs = Substs::trans_empty();
607-
let fcx = new_fn_ctxt(ccx,
608-
llfn,
609-
ast::DUMMY_NODE_ID,
610-
false,
611-
sig.output,
612-
&empty_substs,
613-
None,
614-
&block_arena);
605+
let (block_arena, fcx): (TypedArena<_>, FunctionContext);
606+
block_arena = TypedArena::new();
607+
fcx = new_fn_ctxt(ccx,
608+
llfn,
609+
ast::DUMMY_NODE_ID,
610+
false,
611+
sig.output,
612+
&empty_substs,
613+
None,
614+
&block_arena);
615615
let mut bcx = init_function(&fcx, false, sig.output);
616616

617617
// the first argument (`self`) will be a trait object

src/librustc_typeck/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
10491049
// if there are any.
10501050
assert_eq!(substs.types.len(subst::FnSpace), 0);
10511051
assert_eq!(substs.regions().len(subst::FnSpace), 0);
1052-
let mut substs = substs;
10531052
let placeholder;
1053+
let mut substs = substs;
10541054
if
10551055
!method.generics.types.is_empty_in(subst::FnSpace) ||
10561056
!method.generics.regions.is_empty_in(subst::FnSpace)

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3101,8 +3101,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
31013101
let name = ident.get();
31023102
// only find fits with at least one matching letter
31033103
let mut best_dist = name.len();
3104-
let mut best = None;
31053104
let fields = ty::lookup_struct_fields(tcx, id);
3105+
let mut best = None;
31063106
for elem in fields.iter() {
31073107
let n = elem.name.as_str();
31083108
// ignore already set fields

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
126126
.expect("phase_2_configure_and_expand aborted in rustdoc!");
127127

128128
let mut forest = ast_map::Forest::new(krate);
129+
let arenas = ty::CtxtArenas::new();
129130
let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest);
130131

131-
let arenas = ty::CtxtArenas::new();
132132
let ty::CrateAnalysis {
133133
exported_items, public_items, ty_cx, ..
134134
} = driver::phase_3_run_analysis_passes(sess,

0 commit comments

Comments
 (0)