Skip to content

Commit ecd9c10

Browse files
committed
Move upvar checking into its own pre-pass that occurs before regionck
and which uses EUV. For now, upvar inference is not any smarter than it ever was, but regionck is simpler because it doesn't have to do as many things at once.
1 parent 7474be0 commit ecd9c10

File tree

4 files changed

+385
-339
lines changed

4 files changed

+385
-339
lines changed

src/librustc/middle/def.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ impl TraitItemKind {
126126
}
127127

128128
impl Def {
129+
pub fn local_node_id(&self) -> ast::NodeId {
130+
let def_id = self.def_id();
131+
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
132+
def_id.node
133+
}
134+
129135
pub fn def_id(&self) -> ast::DefId {
130136
match *self {
131137
DefFn(id, _) | DefStaticMethod(id, _) | DefMod(id) |

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub mod regionmanip;
130130
pub mod regionck;
131131
pub mod demand;
132132
pub mod method;
133+
mod upvar;
133134
pub mod wf;
134135
mod closure;
135136
mod callee;
@@ -482,6 +483,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
482483
decl, id, body, &inh);
483484

484485
vtable::select_all_fcx_obligations_or_error(&fcx);
486+
upvar::closure_analyze_fn(&fcx, id, decl, body);
485487
regionck::regionck_fn(&fcx, id, decl, body);
486488
writeback::resolve_type_vars_in_fn(&fcx, decl, body);
487489
}

0 commit comments

Comments
 (0)