Fix clippy errors (#62)

* Move from travis to github actions (#58)

* Added github actions

* Remove travis

* Fixed clippy warnings

* Add the clippy check to ci

* Move workflows to .github

* Fix missing clippy
This commit is contained in:
João Capucho
2020-06-08 21:00:46 +01:00
committed by GitHub
parent b108a50089
commit 706a88e21c
5 changed files with 55 additions and 27 deletions

32
.github/workflows/pipeline.yml vendored Normal file
View File

@@ -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

View File

@@ -1 +0,0 @@
language: rust

View File

@@ -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)?;
}
@@ -881,15 +879,13 @@ 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)?;
} 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")?;
}
write!(self.out, "\t")?;
tyvar.try_fmt(&mut self.out)?;
resolved.try_fmt_decorated(&mut self.out, ";\n")?;
}
}
writeln!(self.out, "}};")?;

View File

@@ -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(())
}
@@ -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(())
}
@@ -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,
function_id,
variable_ids: self.data
.by_ref()
@@ -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(())
}
@@ -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(())
}
@@ -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)
}

View File

@@ -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();
@@ -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,
@@ -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,