diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7d3f7e50..806f6df2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,13 +2,13 @@ 2. [ ] Make sure that the changes are covered by unit-tests. -3. [ ] Run `cargo fmt` on the changes. +3. [ ] Run `cargo +nightly fmt` on the changes. 4. [ ] Please put changelog entries **in the description of this Pull Request** if knowledge of this change could be valuable to users. No need to put the entries to the changelog directly, they will be transferred to the changelog file by maintainers right after the Pull Request merge. - + Please remove any items from the template below that are not applicable. 5. [ ] Describe in common words what is the purpose of this change, related @@ -18,7 +18,7 @@ Changelog: ```markdown ### Public dependency updates - [some_crate](https://crates.io/crates/some_crate) 1.0 - + ### Breaking changes Changes to `Foo`: - Renamed to `Bar`. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fb2896cc..95788b10 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -51,3 +51,11 @@ jobs: run: | cd examples cargo build --verbose + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check formatting + run: | + rustup toolchain install nightly --component rustfmt + cargo +nightly fmt --check diff --git a/.rustfmt.toml b/.rustfmt.toml index 3535f354..1842813a 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,2 +1,2 @@ -# imports_granularity = "Crate" -# group_imports = "One" +imports_granularity = "Crate" +group_imports = "One" diff --git a/examples/deferred/frame/ambient_lighting_system.rs b/examples/deferred/frame/ambient_lighting_system.rs index 181fabec..83866fe9 100644 --- a/examples/deferred/frame/ambient_lighting_system.rs +++ b/examples/deferred/frame/ambient_lighting_system.rs @@ -1,3 +1,4 @@ +use super::LightingVertex; use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, @@ -31,8 +32,6 @@ use vulkano::{ render_pass::Subpass, }; -use super::LightingVertex; - /// Allows applying an ambient lighting to a scene. pub struct AmbientLightingSystem { gfx_queue: Arc, diff --git a/examples/deferred/frame/directional_lighting_system.rs b/examples/deferred/frame/directional_lighting_system.rs index 525d762f..9a248d67 100644 --- a/examples/deferred/frame/directional_lighting_system.rs +++ b/examples/deferred/frame/directional_lighting_system.rs @@ -1,3 +1,4 @@ +use super::LightingVertex; use cgmath::Vector3; use std::sync::Arc; use vulkano::{ @@ -32,8 +33,6 @@ use vulkano::{ render_pass::Subpass, }; -use super::LightingVertex; - /// Allows applying a directional light source to a scene. pub struct DirectionalLightingSystem { gfx_queue: Arc, diff --git a/examples/deferred/frame/mod.rs b/examples/deferred/frame/mod.rs index 628f4492..9955683a 100644 --- a/examples/deferred/frame/mod.rs +++ b/examples/deferred/frame/mod.rs @@ -3,9 +3,8 @@ // The main code is in the `system` module, while the other modules implement the different kinds // of lighting sources. -use vulkano::{buffer::BufferContents, pipeline::graphics::vertex_input::Vertex}; - pub use self::system::{FrameSystem, Pass}; +use vulkano::{buffer::BufferContents, pipeline::graphics::vertex_input::Vertex}; mod ambient_lighting_system; mod directional_lighting_system; diff --git a/examples/deferred/frame/point_lighting_system.rs b/examples/deferred/frame/point_lighting_system.rs index 806bfb92..aacf74fb 100644 --- a/examples/deferred/frame/point_lighting_system.rs +++ b/examples/deferred/frame/point_lighting_system.rs @@ -1,3 +1,4 @@ +use super::LightingVertex; use cgmath::{Matrix4, Vector3}; use std::sync::Arc; use vulkano::{ @@ -32,8 +33,6 @@ use vulkano::{ render_pass::Subpass, }; -use super::LightingVertex; - pub struct PointLightingSystem { gfx_queue: Arc, vertex_buffer: Subbuffer<[LightingVertex]>, diff --git a/vulkano/src/buffer/subbuffer.rs b/vulkano/src/buffer/subbuffer.rs index 442790c1..851d61cb 100644 --- a/vulkano/src/buffer/subbuffer.rs +++ b/vulkano/src/buffer/subbuffer.rs @@ -24,7 +24,6 @@ use std::{ sync::Arc, thread, }; - #[cfg(feature = "macros")] pub use vulkano_macros::BufferContents; diff --git a/vulkano/src/lib.rs b/vulkano/src/lib.rs index 579833c8..27a91d23 100644 --- a/vulkano/src/lib.rs +++ b/vulkano/src/lib.rs @@ -152,6 +152,7 @@ pub use ash::vk::Handle; use bytemuck::{Pod, Zeroable}; +pub use extensions::ExtensionProperties; pub use half; pub use library::{LoadingError, VulkanLibrary}; use std::{ @@ -162,7 +163,7 @@ use std::{ ops::Deref, sync::Arc, }; -pub use {extensions::ExtensionProperties, version::Version}; +pub use version::Version; #[macro_use] mod tests; diff --git a/vulkano/src/macros.rs b/vulkano/src/macros.rs index a8dea17b..9faf1499 100644 --- a/vulkano/src/macros.rs +++ b/vulkano/src/macros.rs @@ -999,4 +999,8 @@ macro_rules! try_opt { }; } -pub(crate) use {impl_id_counter, try_opt, vulkan_bitflags, vulkan_bitflags_enum, vulkan_enum}; +pub(crate) use impl_id_counter; +pub(crate) use try_opt; +pub(crate) use vulkan_bitflags; +pub(crate) use vulkan_bitflags_enum; +pub(crate) use vulkan_enum; diff --git a/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs b/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs index fc951c77..580c6e75 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs @@ -158,7 +158,6 @@ mod tests { use crate::format::Format; #[allow(deprecated)] use crate::pipeline::graphics::vertex_input::Vertex; - use bytemuck::{Pod, Zeroable}; #[test] diff --git a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs index 10a97ee9..2da3db30 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs @@ -105,9 +105,7 @@ impl VertexMemberInfo { #[cfg(test)] mod tests { - use crate::format::Format; - use crate::pipeline::graphics::vertex_input::Vertex; - + use crate::{format::Format, pipeline::graphics::vertex_input::Vertex}; use bytemuck::{Pod, Zeroable}; #[test] diff --git a/vulkano/src/swapchain/surface.rs b/vulkano/src/swapchain/surface.rs index 7ed404dd..8d9354ba 100644 --- a/vulkano/src/swapchain/surface.rs +++ b/vulkano/src/swapchain/surface.rs @@ -1534,8 +1534,7 @@ unsafe fn get_metal_layer_ios(ui_view: *mut c_void) -> IOSMetalLayer { #[cfg(target_os = "macos")] unsafe fn get_metal_layer_macos(ns_view: *mut c_void) -> *mut Object { use core_graphics_types::base::CGFloat; - use objc::runtime::YES; - use objc::runtime::{BOOL, NO}; + use objc::runtime::{BOOL, NO, YES}; let view: *mut Object = ns_view.cast(); let main_layer: *mut Object = msg_send![view, layer]; diff --git a/vulkano/src/sync/fence.rs b/vulkano/src/sync/fence.rs index 0a9ae972..529f2b45 100644 --- a/vulkano/src/sync/fence.rs +++ b/vulkano/src/sync/fence.rs @@ -33,8 +33,8 @@ use crate::{ VulkanObject, }; use smallvec::SmallVec; -use std::fs::File; use std::{ + fs::File, future::Future, mem::MaybeUninit, num::NonZeroU64,