Skip to content

Commit bbbefbf

Browse files
committed
allow(unused) + cargo fmt
1 parent e19eb14 commit bbbefbf

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

src/cuda/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ impl Program {
199199
let bytes_len = mem::size_of_val(slice);
200200

201201
// Transmuting types is safe as long a sizes match.
202-
let bytes = unsafe {
203-
std::slice::from_raw_parts(slice.as_ptr() as *const u8, bytes_len)
204-
};
202+
let bytes = unsafe { std::slice::from_raw_parts(slice.as_ptr() as *const u8, bytes_len) };
205203

206204
// It is only unsafe as long as the buffer isn't initialized, but that's what we do next.
207205
let mut buffer = unsafe { DeviceBuffer::<u8>::uninitialized(bytes_len)? };
@@ -241,10 +239,7 @@ impl Program {
241239

242240
// Transmuting types is safe as long a sizes match.
243241
let bytes = unsafe {
244-
std::slice::from_raw_parts(
245-
data.as_ptr() as *const u8,
246-
mem::size_of_val(data),
247-
)
242+
std::slice::from_raw_parts(data.as_ptr() as *const u8, mem::size_of_val(data))
248243
};
249244

250245
// It is safe as we synchronize the stream after the call.
@@ -260,10 +255,7 @@ impl Program {
260255

261256
// Transmuting types is safe as long a sizes match.
262257
let bytes = unsafe {
263-
std::slice::from_raw_parts_mut(
264-
data.as_mut_ptr() as *mut u8,
265-
mem::size_of_val(data),
266-
)
258+
std::slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, mem::size_of_val(data))
267259
};
268260

269261
// It is safe as we synchronize the stream after the call.

src/cuda/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use crate::error::{GPUError, GPUResult};
1111
// are never used directly, they are only accessed through [`cuda::Device`] which contains an
1212
// `UnownedContext`. A device cannot have an own context itself, as then it couldn't be cloned,
1313
// but that is needed for creating the kernels.
14-
#[allow(dead_code)]
15-
pub(crate) struct CudaContexts(Vec<rustacuda::context::Context>);
14+
pub(crate) struct CudaContexts(#[allow(unused)] Vec<rustacuda::context::Context>);
1615
unsafe impl Sync for CudaContexts {}
1716
unsafe impl Send for CudaContexts {}
1817

src/opencl/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ impl Program {
264264
)?
265265
};
266266
// Transmuting types is safe as long a sizes match.
267-
let bytes = unsafe {
268-
std::slice::from_raw_parts(slice.as_ptr() as *const u8, bytes_len)
269-
};
267+
let bytes = unsafe { std::slice::from_raw_parts(slice.as_ptr() as *const u8, bytes_len) };
270268
// Write some data right-away. This makes a significant performance different.
271269
unsafe {
272270
self.queue
@@ -320,10 +318,7 @@ impl Program {
320318

321319
// It is safe as long as the sizes match.
322320
let bytes = unsafe {
323-
std::slice::from_raw_parts(
324-
data.as_ptr() as *const u8,
325-
mem::size_of_val(data),
326-
)
321+
std::slice::from_raw_parts(data.as_ptr() as *const u8, mem::size_of_val(data))
327322
};
328323
unsafe {
329324
self.queue
@@ -338,10 +333,7 @@ impl Program {
338333

339334
// It is safe as long as the sizes match.
340335
let bytes = unsafe {
341-
std::slice::from_raw_parts_mut(
342-
data.as_mut_ptr() as *mut u8,
343-
mem::size_of_val(data),
344-
)
336+
std::slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, mem::size_of_val(data))
345337
};
346338
unsafe {
347339
self.queue

0 commit comments

Comments
 (0)