Merge pull request #171 from Ralith/reformat

Update to latest rustfmt
This commit is contained in:
Maik Klein 2018-12-09 08:48:43 +01:00 committed by GitHub
commit 65040ecbea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2026 additions and 2046 deletions

View file

@ -5,7 +5,7 @@ os:
language: rust
before_script:
- rustup component add rustfmt-preview
- rustup component add rustfmt
rust:
- stable

View file

@ -17,11 +17,7 @@ const LIB_PATH: &'static str = "vulkan-1.dll";
#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "ios",
target_os = "android"
))
not(any(target_os = "macos", target_os = "ios", target_os = "android"))
))]
const LIB_PATH: &'static str = "libvulkan.so.1";

File diff suppressed because it is too large Load diff

View file

@ -121,7 +121,8 @@ fn main() {
base.device
.create_framebuffer(&frame_buffer_create_info, None)
.unwrap()
}).collect();
})
.collect();
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
let index_buffer_info = vk::BufferCreateInfo {
s_type: vk::StructureType::BUFFER_CREATE_INFO,
@ -139,7 +140,8 @@ fn main() {
&index_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the index buffer.");
)
.expect("Unable to find suitable memorytype for the index buffer.");
let index_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
p_next: ptr::null(),
@ -157,7 +159,8 @@ fn main() {
0,
index_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut index_slice = Align::new(
index_ptr,
align_of::<u32>() as u64,
@ -208,7 +211,8 @@ fn main() {
&vertex_input_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the vertex buffer.");
)
.expect("Unable to find suitable memorytype for the vertex buffer.");
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
@ -227,7 +231,8 @@ fn main() {
0,
vertex_input_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut slice = Align::new(
vert_ptr,
align_of::<Vertex>() as u64,
@ -266,7 +271,8 @@ fn main() {
&uniform_color_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the vertex buffer.");
)
.expect("Unable to find suitable memorytype for the vertex buffer.");
let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
@ -285,7 +291,8 @@ fn main() {
0,
uniform_color_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut uniform_aligned_slice = Align::new(
uniform_ptr,
align_of::<Vector3>() as u64,
@ -316,7 +323,8 @@ fn main() {
&image_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the vertex buffer.");
)
.expect("Unable to find suitable memorytype for the vertex buffer.");
let image_buffer_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
@ -335,7 +343,8 @@ fn main() {
0,
image_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut image_slice = Align::new(
image_ptr,
std::mem::align_of::<u8>() as u64,
@ -377,7 +386,8 @@ fn main() {
&texture_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::DEVICE_LOCAL,
).expect("Unable to find suitable memory index for depth image.");
)
.expect("Unable to find suitable memory index for depth image.");
let texture_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
@ -872,7 +882,8 @@ fn main() {
std::u64::MAX,
base.present_complete_semaphore,
vk::Fence::null(),
).unwrap();
)
.unwrap();
let clear_values = [
vk::ClearValue {
color: vk::ClearColorValue {

View file

@ -110,7 +110,8 @@ fn main() {
base.device
.create_framebuffer(&frame_buffer_create_info, None)
.unwrap()
}).collect();
})
.collect();
let index_buffer_data = [0u32, 1, 2];
let index_buffer_info = vk::BufferCreateInfo {
s_type: vk::StructureType::BUFFER_CREATE_INFO,
@ -128,7 +129,8 @@ fn main() {
&index_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the index buffer.");
)
.expect("Unable to find suitable memorytype for the index buffer.");
let index_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
p_next: ptr::null(),
@ -146,7 +148,8 @@ fn main() {
0,
index_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut index_slice = Align::new(
index_ptr,
align_of::<u32>() as u64,
@ -179,7 +182,8 @@ fn main() {
&vertex_input_buffer_memory_req,
&base.device_memory_properties,
vk::MemoryPropertyFlags::HOST_VISIBLE,
).expect("Unable to find suitable memorytype for the vertex buffer.");
)
.expect("Unable to find suitable memorytype for the vertex buffer.");
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
@ -212,7 +216,8 @@ fn main() {
0,
vertex_input_buffer_memory_req.size,
vk::MemoryMapFlags::empty(),
).unwrap();
)
.unwrap();
let mut vert_align = Align::new(
vert_ptr,
align_of::<Vertex>() as u64,
@ -462,7 +467,8 @@ fn main() {
std::u64::MAX,
base.present_complete_semaphore,
vk::Fence::null(),
).unwrap();
)
.unwrap();
let clear_values = [
vk::ClearValue {
color: vk::ClearColorValue {

View file

@ -67,7 +67,8 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
.reset_command_buffer(
command_buffer,
vk::CommandBufferResetFlags::RELEASE_RESOURCES,
).expect("Reset command buffer failed.");
)
.expect("Reset command buffer failed.");
let command_buffer_begin_info = vk::CommandBufferBeginInfo {
s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
p_next: ptr::null(),
@ -330,7 +331,8 @@ impl ExampleBase {
.with_dimensions(winit::dpi::LogicalSize::new(
window_width as f64,
window_height as f64,
)).build(&events_loop)
))
.build(&events_loop)
.unwrap();
let entry = Entry::new().unwrap();
let app_name = CString::new("VulkanTriangle").unwrap();
@ -402,8 +404,10 @@ impl ExampleBase {
true => Some((*pdevice, index)),
_ => None,
}
}).nth(0)
}).filter_map(|v| v)
})
.nth(0)
})
.filter_map(|v| v)
.nth(0)
.expect("Couldn't find suitable device.");
let queue_family_index = queue_family_index as u32;
@ -449,7 +453,8 @@ impl ExampleBase {
color_space: sfmt.color_space,
},
_ => sfmt.clone(),
}).nth(0)
})
.nth(0)
.expect("Unable to find suitable surface format.");
let surface_capabilities = surface_loader
.get_physical_device_surface_capabilities(pdevice, surface)
@ -553,7 +558,8 @@ impl ExampleBase {
image: image,
};
device.create_image_view(&create_view_info, None).unwrap()
}).collect();
})
.collect();
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
let depth_image_create_info = vk::ImageCreateInfo {
s_type: vk::StructureType::IMAGE_CREATE_INFO,
@ -582,7 +588,8 @@ impl ExampleBase {
&depth_image_memory_req,
&device_memory_properties,
vk::MemoryPropertyFlags::DEVICE_LOCAL,
).expect("Unable to find suitable memory index for depth image.");
)
.expect("Unable to find suitable memory index for depth image.");
let depth_image_allocate_info = vk::MemoryAllocateInfo {
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,

View file

@ -539,7 +539,8 @@ impl CommandExt for vkxml::Command {
.map(|field| match field.basetype.as_str() {
"VkDevice" | "VkCommandBuffer" | "VkQueue" => true,
_ => false,
}).unwrap_or(false);
})
.unwrap_or(false);
match self.name.as_str() {
"vkGetInstanceProcAddr" => FunctionType::Static,
"vkCreateInstance"
@ -704,7 +705,8 @@ fn generate_function_pointers<'a>(
} else {
return false;
}
}).collect();
})
.collect();
let params: Vec<Vec<(Ident, Tokens)>> = commands
.iter()
@ -716,9 +718,11 @@ fn generate_function_pointers<'a>(
let name = field.param_ident();
let ty = field.type_tokens();
(name, ty)
}).collect();
})
.collect();
params
}).collect();
})
.collect();
let params_names: Vec<Vec<_>> = params
.iter()
@ -727,7 +731,8 @@ fn generate_function_pointers<'a>(
.iter()
.map(|&(param_name, _)| param_name)
.collect()
}).collect();
})
.collect();
let param_names_ref = &params_names;
let expanded_params: Vec<_> = params
.iter()
@ -738,7 +743,8 @@ fn generate_function_pointers<'a>(
quote! {
#(#inner_params_iter,)*
}
}).collect();
})
.collect();
let expanded_params_unused: Vec<_> = params
.iter()
.map(|inner_params| {
@ -749,7 +755,8 @@ fn generate_function_pointers<'a>(
quote! {
#(#inner_params_iter,)*
}
}).collect();
})
.collect();
let expanded_params_ref = &expanded_params;
let return_types: Vec<_> = commands
@ -774,9 +781,11 @@ fn generate_function_pointers<'a>(
let name = field.param_ident();
let ty = field.type_tokens();
quote! { #name: #ty }
}).collect();
})
.collect();
params
}).collect();
})
.collect();
let signature_params_ref = &signature_params;
let pfn_return_types: Vec<_> = pfn_commands
@ -867,7 +876,8 @@ pub fn generate_extension_constants<'a>(
.filter_map(|item| match item {
vk_parse::ExtensionChild::Require { items, .. } => Some(items.iter()),
_ => None,
}).flat_map(|iter| iter);
})
.flat_map(|iter| iter);
let enum_tokens = items.filter_map(|item| match item {
vk_parse::InterfaceItem::Enum(_enum) => {
use vk_parse::EnumSpec;
@ -937,7 +947,8 @@ pub fn generate_extension_commands<'a>(
}))
}
_ => None,
}).flat_map(|iter| iter)
})
.flat_map(|iter| iter)
.collect_vec();
let name = format!("{}Fn", extension_name.to_camel_case());
let ident = Ident::from(&name[2..]);
@ -1051,7 +1062,8 @@ pub fn bitflags_impl_block(
let variant_ident = constant.variant_ident(enum_name);
let tokens = constant.to_tokens();
(variant_ident, tokens)
}).collect_vec();
})
.collect_vec();
let notations = constants.iter().map(|constant| {
constant.notation().map(|n| {
@ -1093,7 +1105,8 @@ pub fn generate_enum<'a>(
.filter_map(|elem| match *elem {
vkxml::EnumerationElement::Enum(ref constant) => Some(constant),
_ => None,
}).collect_vec();
})
.collect_vec();
let values = const_values.entry(ident.clone()).or_insert_with(Vec::new);
for constant in &constants {
const_cache.insert(constant.name.as_str());
@ -1202,7 +1215,8 @@ fn is_static_array(field: &vkxml::Field) -> bool {
.map(|ty| match ty {
vkxml::ArrayType::Static => true,
_ => false,
}).unwrap_or(false)
})
.unwrap_or(false)
}
pub fn derive_default(_struct: &vkxml::Struct) -> Option<Tokens> {
let name = name_to_tokens(&_struct.name);
@ -1369,11 +1383,13 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
.clone()
.find(|field| field.param_ident().to_string() == "p_next")
{
Some(p_next) => if p_next.type_tokens().to_string().starts_with("*const") {
Some(p_next) => {
if p_next.type_tokens().to_string().starts_with("*const") {
(true, true)
} else {
(true, false)
},
}
}
None => (false, false),
};
@ -1390,7 +1406,8 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
// Associated _count members
if field.array.is_some() {
if let Some(ref array_size) = field.size {
if !array_size.starts_with("latexmath") && !nofilter_count_members
if !array_size.starts_with("latexmath")
&& !nofilter_count_members
.iter()
.any(|n| *n == &(_struct.name.clone() + "." + field_name))
{
@ -1405,7 +1422,8 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
}
None
}).collect();
})
.collect();
let setters = members.clone().filter_map(|field| {
let param_ident = field.param_ident();
@ -1770,11 +1788,13 @@ pub fn generate_feature<'a>(
} else {
None
}
}).collect()
})
.collect()
} else {
vec![]
}
}).filter_map(|cmd_ref| commands.get(&cmd_ref.name))
})
.filter_map(|cmd_ref| commands.get(&cmd_ref.name))
.fold(
(Vec::new(), Vec::new(), Vec::new(), Vec::new()),
|mut acc, &cmd_ref| {
@ -1939,7 +1959,8 @@ pub fn generate_aliases_of_types<'a>(
.filter_map(|child| match child {
vk_parse::TypesChild::Type(ty) => Some((ty.name.as_ref()?, ty.alias.as_ref()?)),
_ => None,
}).filter_map(|(name, alias)| {
})
.filter_map(|(name, alias)| {
let name_ident = name_to_tokens(name);
if ty_cache.contains(&name_ident) {
return None;
@ -1965,7 +1986,8 @@ pub fn write_source_code(path: &Path) {
.filter_map(|item| match item {
vk_parse::RegistryChild::Extensions(ref ext) => Some(&ext.children),
_ => None,
}).nth(0)
})
.nth(0)
.expect("extension");
let mut ty_cache = HashSet::new();
let aliases: Vec<_> = spec2
@ -1976,7 +1998,8 @@ pub fn write_source_code(path: &Path) {
Some(generate_aliases_of_types(ty, &mut ty_cache))
}
_ => None,
}).collect();
})
.collect();
let spec = vk_parse::parse_file_as_vkxml(path);
let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec
@ -1985,7 +2008,8 @@ pub fn write_source_code(path: &Path) {
.filter_map(|elem| match elem {
vkxml::RegistryElement::Commands(ref cmds) => Some(cmds),
_ => None,
}).flat_map(|cmds| cmds.elements.iter().map(|cmd| (cmd.name.clone(), cmd)))
})
.flat_map(|cmds| cmds.elements.iter().map(|cmd| (cmd.name.clone(), cmd)))
.collect();
let features: Vec<&vkxml::Feature> = spec
@ -1994,7 +2018,8 @@ pub fn write_source_code(path: &Path) {
.filter_map(|elem| match elem {
vkxml::RegistryElement::Features(ref features) => Some(features),
_ => None,
}).flat_map(|features| features.elements.iter())
})
.flat_map(|features| features.elements.iter())
.collect();
let definitions: Vec<&vkxml::DefinitionsElement> = spec
@ -2003,7 +2028,8 @@ pub fn write_source_code(path: &Path) {
.filter_map(|elem| match elem {
vkxml::RegistryElement::Definitions(ref definitions) => Some(definitions),
_ => None,
}).flat_map(|definitions| definitions.elements.iter())
})
.flat_map(|definitions| definitions.elements.iter())
.collect();
let enums: Vec<&vkxml::Enumeration> = spec
@ -2012,12 +2038,14 @@ pub fn write_source_code(path: &Path) {
.filter_map(|elem| match elem {
vkxml::RegistryElement::Enums(ref enums) => Some(enums),
_ => None,
}).flat_map(|enums| {
})
.flat_map(|enums| {
enums.elements.iter().filter_map(|_enum| match *_enum {
vkxml::EnumsElement::Enumeration(ref e) => Some(e),
_ => None,
})
}).collect();
})
.collect();
let constants: Vec<&vkxml::Constant> = spec
.elements
@ -2025,7 +2053,8 @@ pub fn write_source_code(path: &Path) {
.filter_map(|elem| match elem {
vkxml::RegistryElement::Constants(ref constants) => Some(constants),
_ => None,
}).flat_map(|constants| constants.elements.iter())
})
.flat_map(|constants| constants.elements.iter())
.collect();
let mut fn_cache = HashSet::new();
@ -2059,14 +2088,16 @@ pub fn write_source_code(path: &Path) {
&mut const_values,
&mut fn_cache,
)
}).collect_vec();
})
.collect_vec();
let union_types = definitions
.iter()
.filter_map(|def| match def {
vkxml::DefinitionsElement::Union(ref union) => Some(union.name.as_str()),
_ => None,
}).collect::<HashSet<&str>>();
})
.collect::<HashSet<&str>>();
let definition_code: Vec<_> = definitions
.into_iter()