From 284043b6051f42461bd5a8938113b389d1a0b080 Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sat, 25 May 2019 15:25:00 -0400 Subject: [PATCH 1/4] Update to 2018 edition --- ash/Cargo.toml | 1 + ash/src/device.rs | 6 +++--- ash/src/entry.rs | 8 ++++---- ash/src/extensions/experimental/amd.rs | 2 +- ash/src/extensions/ext/debug_marker.rs | 6 +++--- ash/src/extensions/ext/debug_report.rs | 8 ++++---- ash/src/extensions/ext/debug_utils.rs | 6 +++--- ash/src/extensions/khr/android_surface.rs | 8 ++++---- ash/src/extensions/khr/display_swapchain.rs | 8 ++++---- ash/src/extensions/khr/surface.rs | 8 ++++---- ash/src/extensions/khr/swapchain.rs | 8 ++++---- ash/src/extensions/khr/wayland_surface.rs | 8 ++++---- ash/src/extensions/khr/win32_surface.rs | 8 ++++---- ash/src/extensions/khr/xcb_surface.rs | 8 ++++---- ash/src/extensions/khr/xlib_surface.rs | 8 ++++---- ash/src/extensions/mvk/ios_surface.rs | 8 ++++---- ash/src/extensions/mvk/macos_surface.rs | 8 ++++---- ash/src/extensions/nv/mesh_shader.rs | 4 ++-- ash/src/extensions/nv/ray_tracing.rs | 8 ++++---- ash/src/instance.rs | 8 ++++---- ash/src/lib.rs | 6 +++--- ash/src/prelude.rs | 2 +- ash/src/util.rs | 2 +- ash/src/version.rs | 6 +++--- ash/src/vk.rs | 2 +- generator/Cargo.toml | 1 + generator/src/lib.rs | 4 ++-- 27 files changed, 81 insertions(+), 79 deletions(-) diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 0e2bb56..2d2fec2 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -8,6 +8,7 @@ repository = "https://github.com/MaikKlein/ash" readme = "../README.md" keywords = ["vulkan", "graphic"] documentation = "https://docs.rs/ash" +edition = "2018" [dependencies] shared_library = "0.1.9" diff --git a/ash/src/device.rs b/ash/src/device.rs index 5684678..3f4be48 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::mem; use std::os::raw::c_void; use std::ptr; -use vk; -use RawPtr; +use crate::vk; +use crate::RawPtr; #[allow(non_camel_case_types)] pub trait DeviceV1_1: DeviceV1_0 { diff --git a/ash/src/entry.rs b/ash/src/entry.rs index ca6cef3..3f4c4c8 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -1,5 +1,5 @@ -use instance::Instance; -use prelude::*; +use crate::instance::Instance; +use crate::prelude::*; use shared_library::dynamic_library::DynamicLibrary; use std::error::Error; use std::fmt; @@ -9,8 +9,8 @@ use std::os::raw::c_void; use std::path::Path; use std::ptr; use std::sync::Arc; -use vk; -use RawPtr; +use crate::vk; +use crate::RawPtr; #[cfg(windows)] const LIB_PATH: &'static str = "vulkan-1.dll"; diff --git a/ash/src/extensions/experimental/amd.rs b/ash/src/extensions/experimental/amd.rs index a68f057..c43bcb4 100644 --- a/ash/src/extensions/experimental/amd.rs +++ b/ash/src/extensions/experimental/amd.rs @@ -25,7 +25,7 @@ use std::fmt; use std::os::raw::*; -use vk::*; +use crate::vk::*; // Extension: `VK_AMD_gpa_interface` diff --git a/ash/src/extensions/ext/debug_marker.rs b/ash/src/extensions/ext/debug_marker.rs index 11f6ce6..2a25493 100644 --- a/ash/src/extensions/ext/debug_marker.rs +++ b/ash/src/extensions/ext/debug_marker.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{DeviceV1_0, InstanceV1_0}; -use vk; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; #[derive(Clone)] pub struct DebugMarker { diff --git a/ash/src/extensions/ext/debug_report.rs b/ash/src/extensions/ext/debug_report.rs index 1d50117..7a52e31 100644 --- a/ash/src/extensions/ext/debug_report.rs +++ b/ash/src/extensions/ext/debug_report.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct DebugReport { diff --git a/ash/src/extensions/ext/debug_utils.rs b/ash/src/extensions/ext/debug_utils.rs index a8acffd..72af416 100644 --- a/ash/src/extensions/ext/debug_utils.rs +++ b/ash/src/extensions/ext/debug_utils.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use {vk, RawPtr}; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::{vk, RawPtr}; #[derive(Clone)] pub struct DebugUtils { diff --git a/ash/src/extensions/khr/android_surface.rs b/ash/src/extensions/khr/android_surface.rs index d9d343d..b16e2d3 100644 --- a/ash/src/extensions/khr/android_surface.rs +++ b/ash/src/extensions/khr/android_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct AndroidSurface { diff --git a/ash/src/extensions/khr/display_swapchain.rs b/ash/src/extensions/khr/display_swapchain.rs index 29c3b5d..fd5f99d 100644 --- a/ash/src/extensions/khr/display_swapchain.rs +++ b/ash/src/extensions/khr/display_swapchain.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{DeviceV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct DisplaySwapchain { diff --git a/ash/src/extensions/khr/surface.rs b/ash/src/extensions/khr/surface.rs index 03e4867..12c4f39 100644 --- a/ash/src/extensions/khr/surface.rs +++ b/ash/src/extensions/khr/surface.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; use std::ptr; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct Surface { diff --git a/ash/src/extensions/khr/swapchain.rs b/ash/src/extensions/khr/swapchain.rs index ade5d04..32785ad 100644 --- a/ash/src/extensions/khr/swapchain.rs +++ b/ash/src/extensions/khr/swapchain.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; use std::ptr; -use version::{DeviceV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct Swapchain { diff --git a/ash/src/extensions/khr/wayland_surface.rs b/ash/src/extensions/khr/wayland_surface.rs index ec5480d..658ef0e 100644 --- a/ash/src/extensions/khr/wayland_surface.rs +++ b/ash/src/extensions/khr/wayland_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct WaylandSurface { diff --git a/ash/src/extensions/khr/win32_surface.rs b/ash/src/extensions/khr/win32_surface.rs index 72ae7ef..d19b266 100644 --- a/ash/src/extensions/khr/win32_surface.rs +++ b/ash/src/extensions/khr/win32_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct Win32Surface { diff --git a/ash/src/extensions/khr/xcb_surface.rs b/ash/src/extensions/khr/xcb_surface.rs index dbd05e8..55e0931 100644 --- a/ash/src/extensions/khr/xcb_surface.rs +++ b/ash/src/extensions/khr/xcb_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct XcbSurface { diff --git a/ash/src/extensions/khr/xlib_surface.rs b/ash/src/extensions/khr/xlib_surface.rs index aed6ca4..9d579fa 100644 --- a/ash/src/extensions/khr/xlib_surface.rs +++ b/ash/src/extensions/khr/xlib_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct XlibSurface { diff --git a/ash/src/extensions/mvk/ios_surface.rs b/ash/src/extensions/mvk/ios_surface.rs index 4aac1c5..e7364d0 100644 --- a/ash/src/extensions/mvk/ios_surface.rs +++ b/ash/src/extensions/mvk/ios_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct IOSSurface { diff --git a/ash/src/extensions/mvk/macos_surface.rs b/ash/src/extensions/mvk/macos_surface.rs index 9dbf44b..5a33a48 100644 --- a/ash/src/extensions/mvk/macos_surface.rs +++ b/ash/src/extensions/mvk/macos_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{EntryV1_0, InstanceV1_0}; -use vk; -use RawPtr; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct MacOSSurface { diff --git a/ash/src/extensions/nv/mesh_shader.rs b/ash/src/extensions/nv/mesh_shader.rs index c982951..c2fe3c7 100644 --- a/ash/src/extensions/nv/mesh_shader.rs +++ b/ash/src/extensions/nv/mesh_shader.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use std::ffi::CStr; use std::mem; -use version::{DeviceV1_0, InstanceV1_0}; -use vk; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; #[derive(Clone)] pub struct MeshShader { diff --git a/ash/src/extensions/nv/ray_tracing.rs b/ash/src/extensions/nv/ray_tracing.rs index 02aa71f..6d52dbf 100644 --- a/ash/src/extensions/nv/ray_tracing.rs +++ b/ash/src/extensions/nv/ray_tracing.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -use prelude::*; +use crate::prelude::*; use std::ffi::CStr; use std::mem; -use version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; -use vk; -use RawPtr; +use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; +use crate::vk; +use crate::RawPtr; #[derive(Clone)] pub struct RayTracing { diff --git a/ash/src/instance.rs b/ash/src/instance.rs index 4db5ceb..252ea86 100644 --- a/ash/src/instance.rs +++ b/ash/src/instance.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] -use device::Device; -use prelude::*; +use crate::device::Device; +use crate::prelude::*; use std::mem; use std::os::raw::c_char; use std::ptr; -use vk; -use RawPtr; +use crate::vk; +use crate::RawPtr; #[doc = ""] #[derive(Clone)] diff --git a/ash/src/lib.rs b/ash/src/lib.rs index d6e5fc2..3641b93 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -25,9 +25,9 @@ extern crate shared_library; -pub use device::Device; -pub use entry::{Entry, EntryCustom, InstanceError, LoadingError}; -pub use instance::Instance; +pub use crate::device::Device; +pub use crate::entry::{Entry, EntryCustom, InstanceError, LoadingError}; +pub use crate::instance::Instance; mod device; mod entry; diff --git a/ash/src/prelude.rs b/ash/src/prelude.rs index a01406c..b4a888c 100644 --- a/ash/src/prelude.rs +++ b/ash/src/prelude.rs @@ -1,2 +1,2 @@ -use vk; +use crate::vk; pub type VkResult = Result; diff --git a/ash/src/util.rs b/ash/src/util.rs index 178da36..e616bac 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use std::mem::size_of; use std::os::raw::c_void; use std::{io, slice}; -use vk; +use crate::vk; /// `Align` handles dynamic alignment. The is useful for dynamic uniform buffers where /// the alignment might be different. For example a 4x4 f32 matrix has a size of 64 bytes diff --git a/ash/src/version.rs b/ash/src/version.rs index 922f6bf..e6121a8 100644 --- a/ash/src/version.rs +++ b/ash/src/version.rs @@ -1,3 +1,3 @@ -pub use device::{DeviceV1_0, DeviceV1_1}; -pub use entry::{EntryV1_0, EntryV1_1}; -pub use instance::{InstanceV1_0, InstanceV1_1}; +pub use crate::device::{DeviceV1_0, DeviceV1_1}; +pub use crate::entry::{EntryV1_0, EntryV1_1}; +pub use crate::instance::{InstanceV1_0, InstanceV1_1}; diff --git a/ash/src/vk.rs b/ash/src/vk.rs index bcd41b8..4ca01a1 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -18,7 +18,7 @@ pub(crate) unsafe fn ptr_chain_iter(ptr: &mut T) -> impl Iterator u64; - fn from_raw(u64) -> Self; + fn from_raw(_: u64) -> Self; } #[doc = ""] #[macro_export] diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 12ffbd5..215d66b 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -2,6 +2,7 @@ name = "generator" version = "0.1.0" authors = ["Maik Klein "] +edition = "2018" [dependencies] vk-parse = "0.2" diff --git a/generator/src/lib.rs b/generator/src/lib.rs index a63ca4a..6050659 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1432,7 +1432,7 @@ pub fn derive_setters( _ => None, }); - let (has_next, is_next_const) = match members + let (has_next, _is_next_const) = match members .clone() .find(|field| field.param_ident().to_string() == "p_next") { @@ -2275,7 +2275,7 @@ pub fn write_source_code(path: &Path) { pub trait Handle { const TYPE: ObjectType; fn as_raw(self) -> u64; - fn from_raw(u64) -> Self; + fn from_raw(_: u64) -> Self; } #version_macros From 1ba1d46eb258ad9396e65bd54078b70e849327cf Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sat, 25 May 2019 15:34:18 -0400 Subject: [PATCH 2/4] Update generator and examples to edition 2018 --- ash/src/lib.rs | 2 -- ash/tests/constant_size_arrays.rs | 2 +- ash/tests/display.rs | 2 +- examples/Cargo.toml | 1 + examples/src/bin/texture.rs | 4 ---- examples/src/bin/triangle.rs | 3 --- generator/src/bin/generator.rs | 2 +- generator/src/lib.rs | 12 ++++++------ 8 files changed, 10 insertions(+), 18 deletions(-) diff --git a/ash/src/lib.rs b/ash/src/lib.rs index 3641b93..caa2ad3 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -23,8 +23,6 @@ //! ``` //! -extern crate shared_library; - pub use crate::device::Device; pub use crate::entry::{Entry, EntryCustom, InstanceError, LoadingError}; pub use crate::instance::Instance; diff --git a/ash/tests/constant_size_arrays.rs b/ash/tests/constant_size_arrays.rs index f736c0a..74378e9 100644 --- a/ash/tests/constant_size_arrays.rs +++ b/ash/tests/constant_size_arrays.rs @@ -1,4 +1,4 @@ -extern crate ash; +use ash; use ash::vk::{PhysicalDeviceProperties, PipelineColorBlendStateCreateInfo}; diff --git a/ash/tests/display.rs b/ash/tests/display.rs index 8746022..6e46eda 100644 --- a/ash/tests/display.rs +++ b/ash/tests/display.rs @@ -1,4 +1,4 @@ -extern crate ash; + use ash::vk; #[test] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 1ff2abf..27c4cea 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -2,6 +2,7 @@ name = "examples" version = "0.1.0" authors = ["maik klein "] +edition = "2018" [dependencies] winit = "0.16" diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index 42664a5..3fd0976 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -1,7 +1,3 @@ -extern crate ash; -extern crate examples; -extern crate image; - use std::default::Default; use std::ffi::CString; use std::fs::File; diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 0104344..936dea5 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -1,6 +1,3 @@ -extern crate ash; -extern crate examples; - use ash::util::*; use ash::vk; use examples::*; diff --git a/generator/src/bin/generator.rs b/generator/src/bin/generator.rs index c639a2a..9ae054b 100644 --- a/generator/src/bin/generator.rs +++ b/generator/src/bin/generator.rs @@ -1,4 +1,4 @@ -extern crate generator; + use generator::write_source_code; use std::path::Path; diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 6050659..55368a7 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1,14 +1,14 @@ #![recursion_limit = "256"] -extern crate heck; -extern crate itertools; + + #[macro_use] extern crate nom; -extern crate proc_macro2; +use proc_macro2; #[macro_use] extern crate quote; -extern crate syn; -pub extern crate vk_parse; -pub extern crate vkxml; +use syn; +pub use vk_parse; +pub use vkxml; use heck::{CamelCase, ShoutySnakeCase, SnakeCase}; use itertools::Itertools; From 634b61885226b7a6fd89ff343e617f082e8f1140 Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sat, 25 May 2019 15:38:28 -0400 Subject: [PATCH 3/4] Run cargo fmt --- ash/src/device.rs | 4 ++-- ash/src/entry.rs | 4 ++-- ash/src/extensions/experimental/amd.rs | 2 +- ash/src/extensions/ext/debug_marker.rs | 4 ++-- ash/src/extensions/ext/debug_report.rs | 4 ++-- ash/src/extensions/ext/debug_utils.rs | 4 ++-- ash/src/extensions/khr/android_surface.rs | 4 ++-- ash/src/extensions/khr/display_swapchain.rs | 4 ++-- ash/src/extensions/khr/surface.rs | 6 +++--- ash/src/extensions/khr/swapchain.rs | 6 +++--- ash/src/extensions/khr/wayland_surface.rs | 4 ++-- ash/src/extensions/khr/win32_surface.rs | 4 ++-- ash/src/extensions/khr/xcb_surface.rs | 4 ++-- ash/src/extensions/khr/xlib_surface.rs | 4 ++-- ash/src/extensions/mvk/ios_surface.rs | 4 ++-- ash/src/extensions/mvk/macos_surface.rs | 4 ++-- ash/src/extensions/nv/mesh_shader.rs | 4 ++-- ash/src/extensions/nv/ray_tracing.rs | 4 ++-- ash/src/instance.rs | 4 ++-- ash/src/util.rs | 2 +- ash/tests/display.rs | 1 - generator/src/bin/generator.rs | 1 - generator/src/lib.rs | 1 - 23 files changed, 40 insertions(+), 43 deletions(-) diff --git a/ash/src/device.rs b/ash/src/device.rs index 3f4be48..c2ef365 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; +use crate::vk; +use crate::RawPtr; use std::mem; use std::os::raw::c_void; use std::ptr; -use crate::vk; -use crate::RawPtr; #[allow(non_camel_case_types)] pub trait DeviceV1_1: DeviceV1_0 { diff --git a/ash/src/entry.rs b/ash/src/entry.rs index 3f4c4c8..be3d52d 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -1,5 +1,7 @@ use crate::instance::Instance; use crate::prelude::*; +use crate::vk; +use crate::RawPtr; use shared_library::dynamic_library::DynamicLibrary; use std::error::Error; use std::fmt; @@ -9,8 +11,6 @@ use std::os::raw::c_void; use std::path::Path; use std::ptr; use std::sync::Arc; -use crate::vk; -use crate::RawPtr; #[cfg(windows)] const LIB_PATH: &'static str = "vulkan-1.dll"; diff --git a/ash/src/extensions/experimental/amd.rs b/ash/src/extensions/experimental/amd.rs index c43bcb4..33292c3 100644 --- a/ash/src/extensions/experimental/amd.rs +++ b/ash/src/extensions/experimental/amd.rs @@ -23,9 +23,9 @@ * **********************************************************************************************************************/ +use crate::vk::*; use std::fmt; use std::os::raw::*; -use crate::vk::*; // Extension: `VK_AMD_gpa_interface` diff --git a/ash/src/extensions/ext/debug_marker.rs b/ash/src/extensions/ext/debug_marker.rs index 2a25493..eeead34 100644 --- a/ash/src/extensions/ext/debug_marker.rs +++ b/ash/src/extensions/ext/debug_marker.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct DebugMarker { diff --git a/ash/src/extensions/ext/debug_report.rs b/ash/src/extensions/ext/debug_report.rs index 7a52e31..e22cb73 100644 --- a/ash/src/extensions/ext/debug_report.rs +++ b/ash/src/extensions/ext/debug_report.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct DebugReport { diff --git a/ash/src/extensions/ext/debug_utils.rs b/ash/src/extensions/ext/debug_utils.rs index 72af416..8760121 100644 --- a/ash/src/extensions/ext/debug_utils.rs +++ b/ash/src/extensions/ext/debug_utils.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::{vk, RawPtr}; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct DebugUtils { diff --git a/ash/src/extensions/khr/android_surface.rs b/ash/src/extensions/khr/android_surface.rs index b16e2d3..c9286e2 100644 --- a/ash/src/extensions/khr/android_surface.rs +++ b/ash/src/extensions/khr/android_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct AndroidSurface { diff --git a/ash/src/extensions/khr/display_swapchain.rs b/ash/src/extensions/khr/display_swapchain.rs index fd5f99d..c11690b 100644 --- a/ash/src/extensions/khr/display_swapchain.rs +++ b/ash/src/extensions/khr/display_swapchain.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct DisplaySwapchain { diff --git a/ash/src/extensions/khr/surface.rs b/ash/src/extensions/khr/surface.rs index 12c4f39..2ff85b6 100644 --- a/ash/src/extensions/khr/surface.rs +++ b/ash/src/extensions/khr/surface.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; -use std::ptr; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; #[derive(Clone)] pub struct Surface { diff --git a/ash/src/extensions/khr/swapchain.rs b/ash/src/extensions/khr/swapchain.rs index 32785ad..1470246 100644 --- a/ash/src/extensions/khr/swapchain.rs +++ b/ash/src/extensions/khr/swapchain.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; -use std::ptr; use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; #[derive(Clone)] pub struct Swapchain { diff --git a/ash/src/extensions/khr/wayland_surface.rs b/ash/src/extensions/khr/wayland_surface.rs index 658ef0e..b758505 100644 --- a/ash/src/extensions/khr/wayland_surface.rs +++ b/ash/src/extensions/khr/wayland_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct WaylandSurface { diff --git a/ash/src/extensions/khr/win32_surface.rs b/ash/src/extensions/khr/win32_surface.rs index d19b266..939147c 100644 --- a/ash/src/extensions/khr/win32_surface.rs +++ b/ash/src/extensions/khr/win32_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct Win32Surface { diff --git a/ash/src/extensions/khr/xcb_surface.rs b/ash/src/extensions/khr/xcb_surface.rs index 55e0931..8a1c66e 100644 --- a/ash/src/extensions/khr/xcb_surface.rs +++ b/ash/src/extensions/khr/xcb_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct XcbSurface { diff --git a/ash/src/extensions/khr/xlib_surface.rs b/ash/src/extensions/khr/xlib_surface.rs index 9d579fa..e8788c0 100644 --- a/ash/src/extensions/khr/xlib_surface.rs +++ b/ash/src/extensions/khr/xlib_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct XlibSurface { diff --git a/ash/src/extensions/mvk/ios_surface.rs b/ash/src/extensions/mvk/ios_surface.rs index e7364d0..c86f439 100644 --- a/ash/src/extensions/mvk/ios_surface.rs +++ b/ash/src/extensions/mvk/ios_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct IOSSurface { diff --git a/ash/src/extensions/mvk/macos_surface.rs b/ash/src/extensions/mvk/macos_surface.rs index 5a33a48..992f864 100644 --- a/ash/src/extensions/mvk/macos_surface.rs +++ b/ash/src/extensions/mvk/macos_surface.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{EntryV1_0, InstanceV1_0}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct MacOSSurface { diff --git a/ash/src/extensions/nv/mesh_shader.rs b/ash/src/extensions/nv/mesh_shader.rs index c2fe3c7..20e3fea 100644 --- a/ash/src/extensions/nv/mesh_shader.rs +++ b/ash/src/extensions/nv/mesh_shader.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] -use std::ffi::CStr; -use std::mem; use crate::version::{DeviceV1_0, InstanceV1_0}; use crate::vk; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct MeshShader { diff --git a/ash/src/extensions/nv/ray_tracing.rs b/ash/src/extensions/nv/ray_tracing.rs index 6d52dbf..591aa6a 100644 --- a/ash/src/extensions/nv/ray_tracing.rs +++ b/ash/src/extensions/nv/ray_tracing.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] use crate::prelude::*; -use std::ffi::CStr; -use std::mem; use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; use crate::vk; use crate::RawPtr; +use std::ffi::CStr; +use std::mem; #[derive(Clone)] pub struct RayTracing { diff --git a/ash/src/instance.rs b/ash/src/instance.rs index 252ea86..1cb3bf1 100644 --- a/ash/src/instance.rs +++ b/ash/src/instance.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] use crate::device::Device; use crate::prelude::*; +use crate::vk; +use crate::RawPtr; use std::mem; use std::os::raw::c_char; use std::ptr; -use crate::vk; -use crate::RawPtr; #[doc = ""] #[derive(Clone)] diff --git a/ash/src/util.rs b/ash/src/util.rs index e616bac..d2f50d5 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -1,9 +1,9 @@ +use crate::vk; use std::iter::Iterator; use std::marker::PhantomData; use std::mem::size_of; use std::os::raw::c_void; use std::{io, slice}; -use crate::vk; /// `Align` handles dynamic alignment. The is useful for dynamic uniform buffers where /// the alignment might be different. For example a 4x4 f32 matrix has a size of 64 bytes diff --git a/ash/tests/display.rs b/ash/tests/display.rs index 6e46eda..f4131fd 100644 --- a/ash/tests/display.rs +++ b/ash/tests/display.rs @@ -1,4 +1,3 @@ - use ash::vk; #[test] diff --git a/generator/src/bin/generator.rs b/generator/src/bin/generator.rs index 9ae054b..42d33ff 100644 --- a/generator/src/bin/generator.rs +++ b/generator/src/bin/generator.rs @@ -1,4 +1,3 @@ - use generator::write_source_code; use std::path::Path; diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 55368a7..60a26ab 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1,6 +1,5 @@ #![recursion_limit = "256"] - #[macro_use] extern crate nom; use proc_macro2; From fb982fe41973ed84838dd234f33f8092917df82f Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sat, 25 May 2019 16:00:15 -0400 Subject: [PATCH 4/4] Make handle and bitflags constructors functions const Fixes #187 --- ash/src/vk.rs | 12 ++++++------ generator/src/lib.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ash/src/vk.rs b/ash/src/vk.rs index bcd41b8..26be1ca 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -85,19 +85,19 @@ macro_rules! vk_bitflags_wrapped { } impl $name { #[inline] - pub fn empty() -> $name { + pub const fn empty() -> $name { $name(0) } #[inline] - pub fn all() -> $name { + pub const fn all() -> $name { $name($all) } #[inline] - pub fn from_raw(x: $flag_type) -> Self { + pub const fn from_raw(x: $flag_type) -> Self { $name(x) } #[inline] - pub fn as_raw(self) -> $flag_type { + pub const fn as_raw(self) -> $flag_type { self.0 } #[inline] @@ -199,7 +199,7 @@ macro_rules! handle_nondispatchable { } } impl $name { - pub fn null() -> $name { + pub const fn null() -> $name { $name(0) } } @@ -242,7 +242,7 @@ macro_rules! define_handle { unsafe impl Send for $name {} unsafe impl Sync for $name {} impl $name { - pub fn null() -> Self { + pub const fn null() -> Self { $name(::std::ptr::null_mut()) } } diff --git a/generator/src/lib.rs b/generator/src/lib.rs index a63ca4a..68928dc 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -122,7 +122,7 @@ pub fn define_handle_macro() -> Tokens { unsafe impl Sync for $name {} impl $name{ - pub fn null() -> Self{ + pub const fn null() -> Self{ $name(::std::ptr::null_mut()) } } @@ -163,7 +163,7 @@ pub fn handle_nondispatchable_macro() -> Tokens { } impl $name{ - pub fn null() -> $name{ + pub const fn null() -> $name{ $name(0) } } @@ -232,20 +232,20 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens { impl $name { #[inline] - pub fn empty() -> $name { + pub const fn empty() -> $name { $name(0) } #[inline] - pub fn all() -> $name { + pub const fn all() -> $name { $name($all) } #[inline] - pub fn from_raw(x: $flag_type) -> Self { $name(x) } + pub const fn from_raw(x: $flag_type) -> Self { $name(x) } #[inline] - pub fn as_raw(self) -> $flag_type { self.0 } + pub const fn as_raw(self) -> $flag_type { self.0 } #[inline] pub fn is_empty(self) -> bool {