Skip to content

Commit 260a887

Browse files
committed
ir: Add a few edge cases discovered by testing.
1 parent 9ba68b1 commit 260a887

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/ir/item.rs

+11
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,17 @@ impl ItemCanonicalPath for Item {
713713
}
714714

715715
let mut parent_path = self.parent_id().canonical_path(&ctx);
716+
if parent_path.last().map_or(false, |parent_name| parent_name.is_empty()) {
717+
// This only happens (or should only happen) when we're an alias,
718+
// and our parent is a templated alias, in which case the last
719+
// component of the path will be empty.
720+
let is_alias = match *self.expect_type().kind() {
721+
TypeKind::Alias(..) => true,
722+
_ => false,
723+
};
724+
debug_assert!(is_alias, "How can this ever happen?");
725+
parent_path.pop().unwrap();
726+
}
716727
parent_path.push(self.real_canonical_name(ctx, true));
717728

718729
parent_path

src/ir/ty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ impl Type {
473473
ctx);
474474
}
475475
CXCursor_TemplateTypeParameter => {
476+
// See the comment in src/ir/comp.rs
477+
// about the same situation.
478+
if cur.spelling().is_empty() {
479+
return CXChildVisit_Continue;
480+
}
481+
476482
let default_type =
477483
Item::from_ty(&cur.cur_type(),
478484
Some(*cur),

0 commit comments

Comments
 (0)