Upgrade to rustfmt 0.8.0.

Lots of changes this time.

Worked around what looks like a rustfmt bug in parse_inst_operands where
a large match was nested inside Ok().
This commit is contained in:
Jakob Stoklund Olesen
2017-03-14 10:48:05 -07:00
parent 477fb4d5da
commit 010861d58e
37 changed files with 462 additions and 377 deletions

View File

@@ -270,7 +270,10 @@ impl<'a> State<'a> {
// Get the offset following the match that defined `var`, or 0 if var is an environment
// variable or unknown.
fn def_offset(&self, var: &str) -> usize {
self.vars.get(var).map(|&VarDef { offset, .. }| offset).unwrap_or(0)
self.vars
.get(var)
.map(|&VarDef { offset, .. }| offset)
.unwrap_or(0)
}
// Get the offset of the beginning of the next line after `pos`.
@@ -344,13 +347,13 @@ impl<'a> State<'a> {
})
};
Ok(if let Some((b, e)) = matched_range {
let r = (range.0 + b, range.0 + e);
self.recorder.matched_check(rx.as_str(), r);
Some(r)
} else {
self.recorder.missed_check(rx.as_str(), range);
None
})
let r = (range.0 + b, range.0 + e);
self.recorder.matched_check(rx.as_str(), r);
Some(r)
} else {
self.recorder.missed_check(rx.as_str(), range);
None
})
}
}

View File

@@ -148,49 +148,49 @@ impl<'a> Recorder for Explainer<'a> {
fn matched_check(&mut self, regex: &str, matched: MatchRange) {
self.matches.push(Match {
directive: self.directive,
is_match: true,
is_not: false,
regex: regex.to_owned(),
range: matched,
});
directive: self.directive,
is_match: true,
is_not: false,
regex: regex.to_owned(),
range: matched,
});
}
fn matched_not(&mut self, regex: &str, matched: MatchRange) {
self.matches.push(Match {
directive: self.directive,
is_match: true,
is_not: true,
regex: regex.to_owned(),
range: matched,
});
directive: self.directive,
is_match: true,
is_not: true,
regex: regex.to_owned(),
range: matched,
});
}
fn missed_check(&mut self, regex: &str, searched: MatchRange) {
self.matches.push(Match {
directive: self.directive,
is_match: false,
is_not: false,
regex: regex.to_owned(),
range: searched,
});
directive: self.directive,
is_match: false,
is_not: false,
regex: regex.to_owned(),
range: searched,
});
}
fn missed_not(&mut self, regex: &str, searched: MatchRange) {
self.matches.push(Match {
directive: self.directive,
is_match: false,
is_not: true,
regex: regex.to_owned(),
range: searched,
});
directive: self.directive,
is_match: false,
is_not: true,
regex: regex.to_owned(),
range: searched,
});
}
fn defined_var(&mut self, varname: &str, value: &str) {
self.vardefs.push(VarDef {
directive: self.directive,
varname: varname.to_owned(),
value: value.to_owned(),
});
directive: self.directive,
varname: varname.to_owned(),
value: value.to_owned(),
});
}
}

View File

@@ -112,7 +112,7 @@ impl Pattern {
// All remaining possibilities start with `$(`.
if s.len() < 2 || !s.starts_with("$(") {
return Err(Error::Syntax("pattern syntax error, use $$ to match a single $"
.to_string()));
.to_string()));
}
// Match the variable name, allowing for an empty varname in `$()`, or `$(=...)`.
@@ -164,14 +164,14 @@ impl Pattern {
}
let refname = s[refname_begin..refname_end].to_string();
return if let Some(defidx) = def {
Ok((Part::DefVar {
def: defidx,
var: refname,
},
refname_end + 1))
} else {
Err(Error::Syntax(format!("expected variable name in $(=${})", refname)))
};
Ok((Part::DefVar {
def: defidx,
var: refname,
},
refname_end + 1))
} else {
Err(Error::Syntax(format!("expected variable name in $(=${})", refname)))
};
}
// Last case: `$(var=...)` where `...` is a regular expression, possibly containing matched