@@ -164,6 +164,39 @@ struct LoweringContext<'a, 'hir: 'a> {
164
164
allow_gen_future : Option < Lrc < [ Symbol ] > > ,
165
165
}
166
166
167
+ /// Resolution for a lifetime appearing in a type.
168
+ #[ derive( Copy , Clone , Debug ) ]
169
+ pub enum LifetimeRes {
170
+ /// Successfully linked the lifetime to a generic parameter.
171
+ Param {
172
+ /// Id of the generic parameter that introduced it.
173
+ param : NodeId ,
174
+ /// Id of the introducing place. That can be:
175
+ /// - an item's id, for the item's generic parameters;
176
+ /// - a TraitRef's ref_id, identifying the `for<...>` binder;
177
+ /// - a BareFn type's id;
178
+ /// - a Path's id when this path has parenthesized generic args.
179
+ binder : NodeId ,
180
+ /// Whether this parameter was introduced as in-band.
181
+ in_band : bool ,
182
+ /// Whether this parameter was created for anonymous lifetime.
183
+ fresh : Option < usize > ,
184
+ } ,
185
+ /// This will should follow implicit lifetime resolution later.
186
+ Anonymous {
187
+ /// Id of the introducing place. See `Param`.
188
+ binder : NodeId ,
189
+ /// Whether this lifetime was spelled or elided.
190
+ elided : bool ,
191
+ } ,
192
+ /// Explicit `'static` lifetime.
193
+ Static ,
194
+ /// Resolution failure.
195
+ Error ,
196
+ /// HACK: This is used to recover the NodeId of an elided lifetime.
197
+ ElidedAnchor { start : NodeId , end : NodeId } ,
198
+ }
199
+
167
200
pub trait ResolverAstLowering {
168
201
fn def_key ( & mut self , id : DefId ) -> DefKey ;
169
202
@@ -182,6 +215,9 @@ pub trait ResolverAstLowering {
182
215
/// Obtains resolution for a label with the given `NodeId`.
183
216
fn get_label_res ( & mut self , id : NodeId ) -> Option < NodeId > ;
184
217
218
+ /// Obtains resolution for a lifetime with the given `NodeId`.
219
+ fn get_lifetime_res ( & mut self , id : NodeId ) -> Option < LifetimeRes > ;
220
+
185
221
/// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
186
222
/// This should only return `None` during testing.
187
223
fn definitions ( & mut self ) -> & mut Definitions ;
0 commit comments