Replace try macro with '?' (#1130)

This commit is contained in:
Lucas Kent 2018-12-07 11:52:52 +11:00 committed by GitHub
parent 84d6f1b33a
commit f997e9322f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 23 deletions

View File

@ -243,7 +243,7 @@ pub fn reflect(name: &str, spirv: &[u32], dump: bool) -> Result<TokenStream, Err
unsafe {
Ok(#struct_name {
shader: try!(::vulkano::pipeline::shader::ShaderModule::from_words(device, &words))
shader: ::vulkano::pipeline::shader::ShaderModule::from_words(device, &words)?
})
}
}

View File

@ -34,12 +34,14 @@ macro_rules! device_extensions {
let properties: Vec<vk::ExtensionProperties> = unsafe {
let mut num = 0;
try!(check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut())));
check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut()
))?;
let mut properties = Vec::with_capacity(num as usize);
try!(check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr())));
check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr()
))?;
properties.set_len(num as usize);
properties
};
@ -63,12 +65,14 @@ macro_rules! device_extensions {
let properties: Vec<vk::ExtensionProperties> = unsafe {
let mut num = 0;
try!(check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut())));
check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, ptr::null_mut()
))?;
let mut properties = Vec::with_capacity(num as usize);
try!(check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr())));
check_errors(vk.EnumerateDeviceExtensionProperties(
physical_device.internal_object(), ptr::null(), &mut num, properties.as_mut_ptr()
))?;
properties.set_len(num as usize);
properties
};

View File

@ -79,15 +79,15 @@ macro_rules! extensions {
impl fmt::Debug for $sname {
#[allow(unused_assignments)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "["));
write!(f, "[")?;
let mut first = true;
$(
if self.$ext {
if !first { try!(write!(f, ", ")); }
if !first { write!(f, ", ")? }
else { first = false; }
try!(f.write_str(str::from_utf8($s).unwrap()));
f.write_str(str::from_utf8($s).unwrap())?;
}
)*

View File

@ -42,12 +42,14 @@ macro_rules! instance_extensions {
let properties: Vec<vk::ExtensionProperties> = unsafe {
let mut num = 0;
try!(check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, ptr::null_mut())));
check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, ptr::null_mut()
))?;
let mut properties = Vec::with_capacity(num as usize);
try!(check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, properties.as_mut_ptr())));
check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, properties.as_mut_ptr()
))?;
properties.set_len(num as usize);
properties
};
@ -91,12 +93,14 @@ macro_rules! instance_extensions {
let properties: Vec<vk::ExtensionProperties> = unsafe {
let mut num = 0;
try!(check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, ptr::null_mut())));
check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, ptr::null_mut()
))?;
let mut properties = Vec::with_capacity(num as usize);
try!(check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, properties.as_mut_ptr())));
check_errors(entry_points.EnumerateInstanceExtensionProperties(
ptr::null(), &mut num, properties.as_mut_ptr()
))?;
properties.set_len(num as usize);
properties
};

View File

@ -344,9 +344,9 @@ impl DisplayMode {
};
let mut output = mem::uninitialized();
try!(check_errors(vk.CreateDisplayModeKHR(display.device.internal_object(),
check_errors(vk.CreateDisplayModeKHR(display.device.internal_object(),
display.display, &infos, ptr::null(),
&mut output)));
&mut output))?;
output
};

View File

@ -108,7 +108,7 @@ unsafe impl<F> GpuFuture for SemaphoreSignalFuture<F>
unimplemented!() // TODO: how to do that?
/*debug_assert_eq!(builder.num_signal_semaphores(), 0);
builder.add_signal_semaphore(&self.semaphore);
try!(builder.submit(&queue));*/
builder.submit(&queue)?;*/
},
SubmitAnyBuilder::QueuePresent(present) => {
present.submit(&queue)?;