@@ -40,11 +40,13 @@ struct LifetimeContext {
4040
4141enum ScopeChain < ' a > {
4242 ItemScope ( & ' a OptVec < ast:: Lifetime > ) ,
43- FnScope ( ast:: NodeId , & ' a OptVec < ast:: Lifetime > , & ' a ScopeChain < ' a > ) ,
44- BlockScope ( ast:: NodeId , & ' a ScopeChain < ' a > ) ,
43+ FnScope ( ast:: NodeId , & ' a OptVec < ast:: Lifetime > , Scope < ' a > ) ,
44+ BlockScope ( ast:: NodeId , Scope < ' a > ) ,
4545 RootScope
4646}
4747
48+ type Scope < ' a > = & ' a ScopeChain < ' a > ;
49+
4850pub fn krate ( sess : session:: Session , krate : & ast:: Crate )
4951 -> @RefCell < NamedRegionMap > {
5052 let mut ctxt = LifetimeContext {
@@ -56,10 +58,10 @@ pub fn krate(sess: session::Session, krate: &ast::Crate)
5658 ctxt. named_region_map
5759}
5860
59- impl < ' a > Visitor < & ' a ScopeChain < ' a > > for LifetimeContext {
61+ impl < ' a > Visitor < Scope < ' a > > for LifetimeContext {
6062 fn visit_item ( & mut self ,
6163 item : & ast:: Item ,
62- _: & ' a ScopeChain < ' a > ) {
64+ _: Scope < ' a > ) {
6365 let scope = match item. node {
6466 ast:: ItemFn ( ..) | // fn lifetimes get added in visit_fn below
6567 ast:: ItemMod ( ..) |
@@ -84,7 +86,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
8486
8587 fn visit_fn ( & mut self , fk : & visit:: FnKind , fd : & ast:: FnDecl ,
8688 b : & ast:: Block , s : Span , n : ast:: NodeId ,
87- scope : & ' a ScopeChain < ' a > ) {
89+ scope : Scope < ' a > ) {
8890 match * fk {
8991 visit:: FkItemFn ( _, generics, _, _) |
9092 visit:: FkMethod ( _, generics, _) => {
@@ -101,7 +103,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
101103 }
102104
103105 fn visit_ty ( & mut self , ty : & ast:: Ty ,
104- scope : & ' a ScopeChain < ' a > ) {
106+ scope : Scope < ' a > ) {
105107 match ty. node {
106108 ast:: TyClosure ( closure) => {
107109 let scope1 = FnScope ( ty. id , & closure. lifetimes , scope) ;
@@ -125,7 +127,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
125127
126128 fn visit_ty_method ( & mut self ,
127129 m : & ast:: TypeMethod ,
128- scope : & ' a ScopeChain < ' a > ) {
130+ scope : Scope < ' a > ) {
129131 let scope1 = FnScope ( m. id , & m. generics . lifetimes , scope) ;
130132 self . check_lifetime_names ( & m. generics . lifetimes ) ;
131133 debug ! ( "pushing fn scope id={} due to ty_method" , m. id) ;
@@ -135,7 +137,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
135137
136138 fn visit_block ( & mut self ,
137139 b : & ast:: Block ,
138- scope : & ' a ScopeChain < ' a > ) {
140+ scope : Scope < ' a > ) {
139141 let scope1 = BlockScope ( b. id , scope) ;
140142 debug ! ( "pushing block scope {}" , b. id) ;
141143 visit:: walk_block ( self , b, & scope1) ;
@@ -144,7 +146,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
144146
145147 fn visit_lifetime_ref ( & mut self ,
146148 lifetime_ref : & ast:: Lifetime ,
147- scope : & ' a ScopeChain < ' a > ) {
149+ scope : Scope < ' a > ) {
148150 if lifetime_ref. name == special_idents:: statik. name {
149151 self . insert_lifetime ( lifetime_ref, ast:: DefStaticRegion ) ;
150152 return ;
@@ -156,7 +158,7 @@ impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
156158impl LifetimeContext {
157159 fn resolve_lifetime_ref ( & self ,
158160 lifetime_ref : & ast:: Lifetime ,
159- scope : & ScopeChain ) {
161+ scope : Scope ) {
160162 // Walk up the scope chain, tracking the number of fn scopes
161163 // that we pass through, until we find a lifetime with the
162164 // given name or we run out of scopes. If we encounter a code
@@ -211,7 +213,7 @@ impl LifetimeContext {
211213 fn resolve_free_lifetime_ref ( & self ,
212214 scope_id : ast:: NodeId ,
213215 lifetime_ref : & ast:: Lifetime ,
214- scope : & ScopeChain ) {
216+ scope : Scope ) {
215217 // Walk up the scope chain, tracking the outermost free scope,
216218 // until we encounter a scope that contains the named lifetime
217219 // or we run out of scopes.
0 commit comments