Skip to content

Commit 66bf249

Browse files
authored
Fix Rust 1.79 lints and reformat imports (#237)
1 parent b61eb87 commit 66bf249

File tree

8 files changed

+53
-50
lines changed

8 files changed

+53
-50
lines changed

examples/d3d12-buffer-winrs.rs

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
//! Example showcasing [`gpu-allocator`] with types and functions from the [`windows`] crate.
2-
use gpu_allocator::d3d12::{
3-
AllocationCreateDesc, Allocator, AllocatorCreateDesc, ID3D12DeviceVersion, ResourceCategory,
2+
use gpu_allocator::{
3+
d3d12::{
4+
AllocationCreateDesc, Allocator, AllocatorCreateDesc, ID3D12DeviceVersion, ResourceCategory,
5+
},
6+
MemoryLocation,
47
};
5-
use gpu_allocator::MemoryLocation;
68
use log::*;
7-
use windows::core::{Interface, Result};
8-
use windows::Win32::{
9-
Foundation::E_NOINTERFACE,
10-
Graphics::{
11-
Direct3D::{D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_12_0},
12-
Direct3D12::{
13-
D3D12CreateDevice, ID3D12Device, ID3D12Resource,
14-
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, D3D12_RESOURCE_DESC,
15-
D3D12_RESOURCE_DIMENSION_BUFFER, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON,
16-
D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
17-
},
18-
Dxgi::{
19-
Common::{DXGI_FORMAT_UNKNOWN, DXGI_SAMPLE_DESC},
20-
CreateDXGIFactory2, IDXGIAdapter4, IDXGIFactory6, DXGI_ADAPTER_FLAG3_SOFTWARE,
21-
DXGI_ERROR_NOT_FOUND,
9+
use windows::{
10+
core::{Interface, Result},
11+
Win32::{
12+
Foundation::E_NOINTERFACE,
13+
Graphics::{
14+
Direct3D::{D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_12_0},
15+
Direct3D12::{
16+
D3D12CreateDevice, ID3D12Device, ID3D12Resource,
17+
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, D3D12_RESOURCE_DESC,
18+
D3D12_RESOURCE_DIMENSION_BUFFER, D3D12_RESOURCE_FLAG_NONE,
19+
D3D12_RESOURCE_STATE_COMMON, D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
20+
},
21+
Dxgi::{
22+
Common::{DXGI_FORMAT_UNKNOWN, DXGI_SAMPLE_DESC},
23+
CreateDXGIFactory2, IDXGIAdapter4, IDXGIFactory6, DXGI_ADAPTER_FLAG3_SOFTWARE,
24+
DXGI_ERROR_NOT_FOUND,
25+
},
2226
},
2327
},
2428
};

examples/d3d12-buffer.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
//! Example showcasing [`winapi`] interop with [`gpu-allocator`] which is driven by the [`windows`] crate.
2-
use winapi::shared::{dxgiformat, winerror};
3-
use winapi::um::{d3d12, d3dcommon};
4-
use winapi::Interface;
2+
use winapi::{
3+
shared::{dxgiformat, winerror},
4+
um::{d3d12, d3dcommon},
5+
Interface,
6+
};
57

68
mod all_dxgi {
79
pub use winapi::shared::{dxgi1_3::*, dxgi1_6::*, dxgitype::*};
810
}
911

10-
use log::*;
11-
12-
use gpu_allocator::d3d12::{
13-
AllocationCreateDesc, Allocator, AllocatorCreateDesc, ID3D12DeviceVersion, ResourceCategory,
14-
ToWinapi, ToWindows,
12+
use gpu_allocator::{
13+
d3d12::{
14+
AllocationCreateDesc, Allocator, AllocatorCreateDesc, ID3D12DeviceVersion,
15+
ResourceCategory, ToWinapi, ToWindows,
16+
},
17+
MemoryLocation,
1518
};
16-
use gpu_allocator::MemoryLocation;
19+
use log::*;
1720

1821
fn create_d3d12_device(
1922
dxgi_factory: *mut all_dxgi::IDXGIFactory6,

examples/vulkan-buffer.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::default::Default;
22

33
use ash::vk;
4-
use log::info;
5-
6-
use gpu_allocator::vulkan::{
7-
AllocationCreateDesc, AllocationScheme, Allocator, AllocatorCreateDesc,
4+
use gpu_allocator::{
5+
vulkan::{AllocationCreateDesc, AllocationScheme, Allocator, AllocatorCreateDesc},
6+
MemoryLocation,
87
};
9-
use gpu_allocator::MemoryLocation;
8+
use log::info;
109

1110
fn main() {
1211
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init();

src/d3d12/mod.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
#![deny(clippy::unimplemented, clippy::unwrap_used, clippy::ok_expect)]
2-
31
use std::{backtrace::Backtrace, fmt, sync::Arc};
42

53
use log::{debug, warn, Level};
6-
74
use windows::Win32::{
85
Foundation::E_OUTOFMEMORY,
96
Graphics::{Direct3D12::*, Dxgi::Common::DXGI_FORMAT},
107
};
118

129
#[cfg(feature = "public-winapi")]
1310
mod public_winapi {
14-
use super::*;
1511
pub use winapi::um::d3d12 as winapi_d3d12;
1612

13+
use super::*;
14+
1715
/// Trait similar to [`AsRef`]/[`AsMut`],
1816
pub trait ToWinapi<T> {
1917
fn as_winapi(&self) -> *const T;
@@ -84,9 +82,7 @@ mod visualizer;
8482
#[cfg(feature = "visualizer")]
8583
pub use visualizer::AllocatorVisualizer;
8684

87-
use super::allocator;
88-
use super::allocator::AllocationType;
89-
85+
use super::{allocator, allocator::AllocationType};
9086
use crate::{
9187
allocator::{AllocatorReport, MemoryBlockReport},
9288
AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
@@ -197,10 +193,12 @@ impl<'a> AllocationCreateDesc<'a> {
197193
desc: &winapi_d3d12::D3D12_RESOURCE_DESC,
198194
name: &'a str,
199195
location: MemoryLocation,
200-
) -> AllocationCreateDesc<'a> {
196+
) -> Self {
201197
let device = device.as_windows();
202198
// Raw structs are binary-compatible
203-
let desc = unsafe { std::mem::transmute(desc) };
199+
let desc = unsafe {
200+
std::mem::transmute::<&winapi_d3d12::D3D12_RESOURCE_DESC, &D3D12_RESOURCE_DESC>(desc)
201+
};
204202
let allocation_info =
205203
unsafe { device.GetResourceAllocationInfo(0, std::slice::from_ref(desc)) };
206204
let resource_category: ResourceCategory = desc.into();
@@ -223,7 +221,7 @@ impl<'a> AllocationCreateDesc<'a> {
223221
desc: &D3D12_RESOURCE_DESC,
224222
name: &'a str,
225223
location: MemoryLocation,
226-
) -> AllocationCreateDesc<'a> {
224+
) -> Self {
227225
let allocation_info =
228226
unsafe { device.GetResourceAllocationInfo(0, std::slice::from_ref(desc)) };
229227
let resource_category: ResourceCategory = desc.into();

src/d3d12/visualizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![allow(clippy::new_without_default)]
22

3+
use windows::Win32::Graphics::Direct3D12::*;
4+
35
use super::Allocator;
46
use crate::visualizer::{
57
render_allocation_reports_ui, AllocationReportVisualizeSettings, ColorScheme,
68
MemoryChunksVisualizationSettings,
79
};
810

9-
use windows::Win32::Graphics::Direct3D12::*;
10-
1111
struct AllocatorVisualizerBlockWindow {
1212
memory_type_index: usize,
1313
block_index: usize,

src/metal/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![deny(clippy::unimplemented, clippy::unwrap_used, clippy::ok_expect)]
22
use std::{backtrace::Backtrace, sync::Arc};
33

4+
use log::debug;
5+
46
use crate::{
57
allocator::{self, AllocatorReport, MemoryBlockReport},
68
AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
79
};
8-
use log::debug;
910

1011
fn memory_location_to_metal(location: MemoryLocation) -> metal::MTLResourceOptions {
1112
match location {

src/visualizer/memory_chunks.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::backtrace::BacktraceStatus;
22

33
use egui::{Color32, DragValue, Rect, ScrollArea, Sense, Ui, Vec2};
44

5-
use crate::allocator::free_list_allocator::MemoryChunk;
6-
75
use super::ColorScheme;
6+
use crate::allocator::free_list_allocator::MemoryChunk;
87

98
pub(crate) struct MemoryChunksVisualizationSettings {
109
pub width_in_bytes: u64,

src/vulkan/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
#[cfg(feature = "visualizer")]
44
mod visualizer;
5-
#[cfg(feature = "visualizer")]
6-
pub use visualizer::AllocatorVisualizer;
7-
85
use std::{backtrace::Backtrace, fmt, marker::PhantomData, sync::Arc};
96

107
use ash::vk;
118
use log::{debug, Level};
9+
#[cfg(feature = "visualizer")]
10+
pub use visualizer::AllocatorVisualizer;
1211

1312
use super::allocator;
1413
use crate::{

0 commit comments

Comments
 (0)