Lint fixes (#99)

* Replace a single-character string literal with a character literal.

* Use is_some() instead of comparing with Some(_).

* Add code-quotes around type names in comments.

* Use !...is_empty() instead of len() != 0.

* Tidy up redundant returns.

* Remove redundant .clone() calls.

* Remove unnecessary explicit lifetime parameters.

* Tidy up unnecessary '&'s.

* Add parens to make operator precedence explicit.

* Use debug_assert_eq instead of debug_assert with ==.

* Replace a &Vec argument with a &[...].

* Replace `a = a op b` with `a op= b`.

* Avoid unnecessary closures.

* Avoid .iter() and .iter_mut() for iterating over containers.

* Remove unneeded qualification.
This commit is contained in:
Dan Gohman
2017-06-19 16:24:10 -07:00
committed by Jakob Stoklund Olesen
parent 3693735874
commit 0c7316ae28
24 changed files with 132 additions and 137 deletions

View File

@@ -247,10 +247,11 @@ impl DataFlowGraph {
// Try to create short alias chains by finding the original source value.
// This also avoids the creation of loops.
let original = self.resolve_aliases(src);
assert!(dest != original,
"Aliasing {} to {} would create a loop",
dest,
src);
assert_ne!(dest,
original,
"Aliasing {} to {} would create a loop",
dest,
src);
let ty = self.value_type(original);
assert_eq!(self.value_type(dest),
ty,
@@ -326,8 +327,8 @@ pub enum ValueDef {
impl ValueDef {
/// Unwrap the instruction where the value was defined, or panic.
pub fn unwrap_inst(&self) -> Inst {
match self {
&ValueDef::Res(inst, _) => inst,
match *self {
ValueDef::Res(inst, _) => inst,
_ => panic!("Value is not an instruction result"),
}
}