Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Fix clippy errors and add clippy to github actions (#60)
Browse files Browse the repository at this point in the history
* Added github actions

* Remove travis

* Fixed clippy warnings

* Add the clippy check to ci

* Move workflows to .github
  • Loading branch information
JCapucho authored and kvark committed Jun 8, 2020
1 parent b108a50 commit f3bdf74
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: pipeline
on: [push, pull_request]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
17 changes: 5 additions & 12 deletions src/back/msl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,8 @@ impl<W: Write> Writer<W> {
return Ok(MaybeOwned::Borrowed(base_inner));
}
}
} else {
if let crate::TypeInner::Struct { .. } = *inner {
} else if let crate::TypeInner::Struct { .. } = *inner {
return Ok(MaybeOwned::Borrowed(inner));
}
}
write!(self.out, "{}.", OUTPUT_STRUCT_NAME)?;
}
Expand Down Expand Up @@ -881,15 +879,10 @@ impl<W: Write> Writer<W> {
resolved.try_fmt_decorated(&mut self.out, ";\n")?;
}
}
} else {
if let Some(ref binding@crate::Binding::Location(_)) = var.binding {
let tyvar = TypedGlobalVariable { module, handle, usage: crate::GlobalUse::empty() };
let resolved = options.resolve_binding(binding, in_mode)?;

write!(self.out, "\t")?;
tyvar.try_fmt(&mut self.out)?;
resolved.try_fmt_decorated(&mut self.out, ";\n")?;
}
} else if let Some(ref binding@crate::Binding::Location(_)) = var.binding {
let tyvar = TypedGlobalVariable { module, handle, usage: crate::GlobalUse::empty() };
let resolved = options.resolve_binding(binding, in_mode)?;
writeln!(self.out, "\t{} [[{}]];", tyvar, resolved)?;
}
}
writeln!(self.out, "}};")?;
Expand Down
25 changes: 13 additions & 12 deletions src/front/spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
return Err(Error::InvalidOperand);
}
if !SUPPORTED_EXTENSIONS.contains(&name.as_str()) {
return Err(Error::UnsupportedExtension(name.to_owned()));
return Err(Error::UnsupportedExtension(name));
}
Ok(())
}
Expand All @@ -777,7 +777,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
return Err(Error::InvalidOperand);
}
if !SUPPORTED_EXT_SETS.contains(&name.as_str()) {
return Err(Error::UnsupportedExtSet(name.to_owned()));
return Err(Error::UnsupportedExtSet(name));
}
Ok(())
}
Expand All @@ -804,7 +804,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
let (name, left) = self.next_string(inst.wc - 3)?;
let ep = EntryPoint {
exec_model,
name: name.to_owned(),
name: name,
function_id,
variable_ids: self.data
.by_ref()
Expand Down Expand Up @@ -852,7 +852,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
self.future_decor
.entry(id)
.or_default()
.name = Some(name.to_owned());
.name = Some(name);
Ok(())
}

Expand All @@ -868,7 +868,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
self.future_member_decor
.entry((id, member))
.or_default()
.name = Some(name.to_owned());
.name = Some(name);
Ok(())
}

Expand Down Expand Up @@ -1266,14 +1266,15 @@ impl<I: Iterator<Item = u32>> Parser<I> {
crate::ConstantInner::Uint((u64::from(high) << 32) | u64::from(low))
}
crate::TypeInner::Scalar { kind: crate::ScalarKind::Sint, width } => {
use std::cmp::Ordering;
let low = self.next()?;
let high = if width < 32 {
return Err(Error::InvalidTypeWidth(u32::from(width)));
} else if width > 32 {
inst.expect(4)?;
self.next()?
} else {
!0
let high = match width.cmp(&32) {
Ordering::Less => return Err(Error::InvalidTypeWidth(u32::from(width))),
Ordering::Greater => {
inst.expect(4)?;
self.next()?
},
Ordering::Equal => !0
};
crate::ConstantInner::Sint(((u64::from(high) << 32) | u64::from(low)) as i64)
}
Expand Down
6 changes: 3 additions & 3 deletions src/front/wgsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl Parser {
self.scopes.pop();
return Ok(*handle);
}
if self.std_namespace.as_ref().map(|s| s.as_str()) == Some(word) {
if self.std_namespace.as_deref() == Some(word) {
lexer.expect(Token::DoubleColon)?;
let name = lexer.next_ident()?;
let mut arguments = Vec::new();
Expand Down Expand Up @@ -575,7 +575,7 @@ impl Parser {
crate::TypeInner::Struct { ref members } => {
let index = members
.iter()
.position(|m| m.name.as_ref().map(|s| s.as_str()) == Some(name))
.position(|m| m.name.as_deref() == Some(name))
.ok_or(Error::BadAccessor(name))? as u32;
crate::Expression::AccessIndex {
base: handle,
Expand Down Expand Up @@ -1354,7 +1354,7 @@ impl Parser {
lexer.expect(Token::Separator(';'))?;
let (fun_handle, _) = module.functions
.iter()
.find(|(_, fun)| fun.name.as_ref().map(|s| s.as_str()) == Some(fun_ident))
.find(|(_, fun)| fun.name.as_deref() == Some(fun_ident))
.ok_or(Error::UnknownFunction(fun_ident))?;
module.entry_points.push(crate::EntryPoint {
exec_model,
Expand Down

0 comments on commit f3bdf74

Please sign in to comment.