summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Kulp <darren@kulp.ch>2020-06-21 17:56:34 -0700
committerEmilio Cobos Álvarez <emilio@crisal.io>2022-03-15 03:54:37 +0100
commite3a6b8cd2b32a0cefbfc62c7bf14aee74f5d722a (patch)
tree84ed1a0b4661768118d45cfd7b69ae0d88595fde
parent63237152212457f956bde9f540cb60836f93dd3f (diff)
ir: Make TargetInfo::new infallible
Now that we require Clang 5.0, there is no way for this function to return None.
-rw-r--r--src/clang.rs6
-rw-r--r--src/ir/context.rs12
2 files changed, 6 insertions, 12 deletions
diff --git a/src/clang.rs b/src/clang.rs
index eb5ff6e1..587cc0ba 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -2065,7 +2065,7 @@ pub struct TargetInfo {
impl TargetInfo {
/// Tries to obtain target information from libclang.
- pub fn new(tu: &TranslationUnit) -> Option<Self> {
+ pub fn new(tu: &TranslationUnit) -> Self {
let triple;
let pointer_width;
unsafe {
@@ -2076,9 +2076,9 @@ impl TargetInfo {
}
assert!(pointer_width > 0);
assert_eq!(pointer_width % 8, 0);
- Some(TargetInfo {
+ TargetInfo {
triple,
pointer_width: pointer_width as usize,
- })
+ }
}
}
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 9afd16d6..9cf43ec3 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -368,7 +368,7 @@ pub struct BindgenContext {
translation_unit: clang::TranslationUnit,
/// Target information that can be useful for some stuff.
- target_info: Option<clang::TargetInfo>,
+ target_info: clang::TargetInfo,
/// The options given by the user via cli or other medium.
options: BindgenOptions,
@@ -584,10 +584,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
/// Returns `true` if the target architecture is wasm32
pub fn is_target_wasm32(&self) -> bool {
- match self.target_info {
- Some(ref ti) => ti.triple.starts_with("wasm32-"),
- None => false,
- }
+ self.target_info.triple.starts_with("wasm32-")
}
/// Creates a timer for the current bindgen phase. If time_phases is `true`,
@@ -600,10 +597,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
/// Returns the pointer width to use for the target for the current
/// translation.
pub fn target_pointer_size(&self) -> usize {
- if let Some(ref ti) = self.target_info {
- return ti.pointer_width / 8;
- }
- mem::size_of::<*mut ()>()
+ return self.target_info.pointer_width / 8;
}
/// Get the stack of partially parsed types that we are in the middle of