@@ -202,13 +202,8 @@ impl Path<'_> {
202202pub struct PathSegment < ' hir > {
203203 /// The identifier portion of this path segment.
204204 pub ident : Ident ,
205- // `id` and `res` are optional. We currently only use these in save-analysis,
206- // any path segments without these will not have save-analysis info and
207- // therefore will not have 'jump to def' in IDEs, but otherwise will not be
208- // affected. (In general, we don't bother to get the defs for synthesized
209- // segments, only for segments which have come from the AST).
210- pub hir_id : Option < HirId > ,
211- pub res : Option < Res > ,
205+ pub hir_id : HirId ,
206+ pub res : Res ,
212207
213208 /// Type/lifetime parameters attached to this path. They come in
214209 /// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`. Note that
@@ -226,12 +221,12 @@ pub struct PathSegment<'hir> {
226221
227222impl < ' hir > PathSegment < ' hir > {
228223 /// Converts an identifier to the corresponding segment.
229- pub fn from_ident ( ident : Ident ) -> PathSegment < ' hir > {
230- PathSegment { ident, hir_id : None , res : None , infer_args : true , args : None }
224+ pub fn new ( ident : Ident , hir_id : HirId , res : Res ) -> PathSegment < ' hir > {
225+ PathSegment { ident, hir_id, res, infer_args : true , args : None }
231226 }
232227
233228 pub fn invalid ( ) -> Self {
234- Self :: from_ident ( Ident :: empty ( ) )
229+ Self :: new ( Ident :: empty ( ) , HirId :: INVALID , Res :: Err )
235230 }
236231
237232 pub fn args ( & self ) -> & GenericArgs < ' hir > {
0 commit comments