diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-03 07:35:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 07:35:58 -0500 |
commit | b28518595c4505d07593eed3d20050f56d200c6b (patch) | |
tree | a4f7c2b9cd06d722912706fe8bcb26937a99e940 | |
parent | ff12c0cb988ad8bb6290e638423ad9cde6bdef8f (diff) | |
parent | 94136d22aae3b92ef66f7673641f7935b76fd98d (diff) |
Auto merge of #191 - glasserc:specialized-optional, r=emilio
Make clang::Cursor::specialized return an Option
Fixes #122.
pair=@Natim
-rwxr-xr-x | src/clang.rs | 11 | ||||
-rw-r--r-- | src/ir/comp.rs | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/clang.rs b/src/clang.rs index 57c42eaf..18216125 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -182,7 +182,7 @@ impl Cursor { /// Is the referent a template specialization? pub fn is_template(&self) -> bool { - self.specialized().is_valid() + self.specialized().is_some() } /// Is the referent a fully specialized template specialization without any @@ -282,11 +282,12 @@ impl Cursor { /// Given that this cursor points to a template specialization, get a cursor /// pointing to the template definition that is being specialized. - pub fn specialized(&self) -> Cursor { + pub fn specialized(&self) -> Option<Cursor> { unsafe { - Cursor { - x: clang_getSpecializedCursorTemplate(self.x), - } + let ret = Cursor { + x: clang_getSpecializedCursorTemplate(self.x) + }; + if ret.is_valid() { Some(ret) } else { None } } } diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 22082772..41e5c3d3 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -512,7 +512,8 @@ impl CompInfo { } }; - ci.ref_template = Item::parse(cursor.specialized(), None, ctx).ok(); + ci.ref_template = cursor.specialized() + .and_then(|c| Item::parse(c, None, ctx).ok()); let mut maybe_anonymous_struct_field = None; cursor.visit(|cur| { |