Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions crates/cuda_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,12 @@ fn find_in_dir(dir: &Path, filename: &str) -> Option<PathBuf> {
continue;
}

if let Some(name) = path.file_name().and_then(|s| s.to_str())
&& (name == filename
|| (name.starts_with(&hashed_prefix) && name.ends_with(dll_suffix)))
{
return Some(path);
if let Some(name) = path.file_name().and_then(|s| s.to_str()) {
if name == filename
|| (name.starts_with(&hashed_prefix) && name.ends_with(dll_suffix))
{
return Some(path);
}
}
}
}
Expand Down Expand Up @@ -586,11 +587,12 @@ fn workspace_root_dir() -> Option<PathBuf> {

loop {
let candidate = path.join("Cargo.toml");
if candidate.is_file()
&& let Ok(contents) = fs::read_to_string(&candidate)
&& contents.contains("[workspace]")
{
return Some(path.clone());
if candidate.is_file() {
if let Ok(contents) = fs::read_to_string(&candidate) {
if contents.contains("[workspace]") {
return Some(path.clone());
}
}
}

if !path.pop() {
Expand Down
4 changes: 2 additions & 2 deletions crates/cust/src/memory/device/device_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ impl<A: DeviceCopy + Pod> DeviceBuffer<A> {
#[cfg_attr(docsrs, doc(cfg(feature = "bytemuck")))]
pub fn try_cast<B: Pod + DeviceCopy>(self) -> Result<DeviceBuffer<B>, PodCastError> {
if align_of::<B>() > align_of::<A>()
&& !(self.buf.as_raw() as usize).is_multiple_of(align_of::<B>())
&& (self.buf.as_raw() as usize) % align_of::<B>() != 0
{
Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned)
} else if size_of::<B>() == size_of::<A>() {
// SAFETY: we made sure sizes were compatible, and DeviceBuffer is repr(C)
Ok(unsafe { transmute::<DeviceBuffer<A>, DeviceBuffer<B>>(self) })
} else if size_of::<A>() == 0 || size_of::<B>() == 0 {
Err(PodCastError::SizeMismatch)
} else if (size_of::<A>() * self.len).is_multiple_of(size_of::<B>()) {
} else if (size_of::<A>() * self.len) % size_of::<B>() == 0 {
let new_len = (size_of::<A>() * self.len) / size_of::<B>();
let ret = Ok(DeviceBuffer {
buf: self.buf.cast(),
Expand Down
2 changes: 1 addition & 1 deletion crates/cust_raw/build/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl FunctionRenames {
Ok(expanded) => expanded,
Err(e) => panic!("Failed to expand macros: {e}"),
};
let expanded = str::from_utf8(&expanded).unwrap();
let expanded = std::str::from_utf8(&expanded).unwrap();

let mut remaps = bimap::BiHashMap::new();
for line in expanded.lines().rev() {
Expand Down
16 changes: 8 additions & 8 deletions crates/ptx/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,14 @@ impl<'src> Lexer<'src> {
let cur = self.cur;
let ident = self.eat_until(|c, _| is_ident_continue(c));
// check if its an instruction
if ident.chars().all(|c| c.is_ascii_alphanumeric())
&& let Ok(kind) = InstructionKind::from_str(ident.as_str())
{
*self.values.last_mut().unwrap() = Some(TokenValue::Instruction(kind));
return Token {
kind: TokenKind::Instruction,
range: cur..self.cur,
};
if ident.chars().all(|c| c.is_ascii_alphanumeric()) {
if let Ok(kind) = InstructionKind::from_str(ident.as_str()) {
*self.values.last_mut().unwrap() = Some(TokenValue::Instruction(kind));
return Token {
kind: TokenKind::Instruction,
range: cur..self.cur,
};
}
}

*self.values.last_mut().unwrap() =
Expand Down
Loading