Make hir::PathSegment::hir_id
non-optional.
This commit is contained in:
parent
6d850d936b
commit
bb0ae3c446
16 changed files with 103 additions and 97 deletions
|
@ -203,7 +203,7 @@ pub struct PathSegment<'hir> {
|
|||
/// The identifier portion of this path segment.
|
||||
pub ident: Ident,
|
||||
|
||||
pub hir_id: Option<HirId>,
|
||||
pub hir_id: HirId,
|
||||
|
||||
pub res: Res,
|
||||
|
||||
|
@ -223,12 +223,12 @@ pub struct PathSegment<'hir> {
|
|||
|
||||
impl<'hir> PathSegment<'hir> {
|
||||
/// Converts an identifier to the corresponding segment.
|
||||
pub fn from_ident(ident: Ident, res: Res) -> PathSegment<'hir> {
|
||||
PathSegment { ident, hir_id: None, res, infer_args: true, args: None }
|
||||
pub fn from_ident(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
|
||||
PathSegment { ident, hir_id, res, infer_args: true, args: None }
|
||||
}
|
||||
|
||||
pub fn invalid() -> Self {
|
||||
Self::from_ident(Ident::empty(), Res::Err)
|
||||
Self::from_ident(Ident::empty(), HirId::INVALID, Res::Err)
|
||||
}
|
||||
|
||||
pub fn args(&self) -> &GenericArgs<'hir> {
|
||||
|
|
|
@ -20,6 +20,9 @@ pub struct HirId {
|
|||
}
|
||||
|
||||
impl HirId {
|
||||
/// Signal local id which should never be used.
|
||||
pub const INVALID: HirId = HirId { owner: CRATE_DEF_ID, local_id: ItemLocalId::INVALID };
|
||||
|
||||
#[inline]
|
||||
pub fn expect_owner(self) -> LocalDefId {
|
||||
assert_eq!(self.local_id.index(), 0);
|
||||
|
|
|
@ -724,7 +724,7 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>(
|
|||
segment: &'v PathSegment<'v>,
|
||||
) {
|
||||
visitor.visit_ident(segment.ident);
|
||||
walk_list!(visitor, visit_id, segment.hir_id);
|
||||
visitor.visit_id(segment.hir_id);
|
||||
if let Some(ref args) = segment.args {
|
||||
visitor.visit_generic_args(path_span, args);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue