Skip to content

Commit ca784c4

Browse files
committed
Make TargetInfo::new infallible
It is not clear why this interface was fallible previously anyway.
1 parent 82611d7 commit ca784c4

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/clang.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ pub struct TargetInfo {
20382038

20392039
impl TargetInfo {
20402040
/// Tries to obtain target information from libclang.
2041-
pub fn new(tu: &TranslationUnit) -> Option<Self> {
2041+
pub fn new(tu: &TranslationUnit) -> Self {
20422042
let triple;
20432043
let pointer_width;
20442044
unsafe {
@@ -2049,9 +2049,9 @@ impl TargetInfo {
20492049
}
20502050
assert!(pointer_width > 0);
20512051
assert_eq!(pointer_width % 8, 0);
2052-
Some(TargetInfo {
2052+
TargetInfo {
20532053
triple,
20542054
pointer_width: pointer_width as usize,
2055-
})
2055+
}
20562056
}
20572057
}

src/ir/context.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ pub struct BindgenContext {
368368
translation_unit: clang::TranslationUnit,
369369

370370
/// Target information that can be useful for some stuff.
371-
target_info: Option<clang::TargetInfo>,
371+
target_info: clang::TargetInfo,
372372

373373
/// The options given by the user via cli or other medium.
374374
options: BindgenOptions,
@@ -595,10 +595,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
595595
/// Returns the pointer width to use for the target for the current
596596
/// translation.
597597
pub fn target_pointer_size(&self) -> usize {
598-
if let Some(ref ti) = self.target_info {
599-
return ti.pointer_width / 8;
600-
}
601-
mem::size_of::<*mut ()>()
598+
return self.target_info.pointer_width / 8;
602599
}
603600

604601
/// Get the stack of partially parsed types that we are in the middle of

0 commit comments

Comments
 (0)