This commit is contained in:
mcarton 2016-02-29 17:48:20 +01:00
parent 578750aae1
commit c7db94aee6
3 changed files with 10 additions and 16 deletions

View File

@ -22,9 +22,7 @@ pub struct BlackListedName {
impl BlackListedName {
pub fn new(blacklist: Vec<String>) -> BlackListedName {
BlackListedName {
blacklist: blacklist
}
BlackListedName { blacklist: blacklist }
}
}
@ -38,7 +36,10 @@ impl LateLintPass for BlackListedName {
fn check_pat(&mut self, cx: &LateContext, pat: &Pat) {
if let PatKind::Ident(_, ref ident, _) = pat.node {
if self.blacklist.iter().any(|s| s == &*ident.node.name.as_str()) {
span_lint(cx, BLACKLISTED_NAME, pat.span, &format!("use of a blacklisted/placeholder name `{}`", ident.node.name));
span_lint(cx,
BLACKLISTED_NAME,
pat.span,
&format!("use of a blacklisted/placeholder name `{}`", ident.node.name));
}
}
}

View File

@ -19,7 +19,7 @@ pub fn conf_file(args: &[ptr::P<ast::MetaItem>]) -> Result<Option<token::Interne
Ok(Some(file.clone()))
} else {
Err(("`conf_file` value must be a string", value.span))
}
};
}
}
}
@ -40,9 +40,7 @@ pub enum ConfError {
impl fmt::Display for ConfError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
ConfError::IoError(ref err) => {
err.fmt(f)
}
ConfError::IoError(ref err) => err.fmt(f),
ConfError::TomlError(ref errs) => {
let mut first = true;
for err in errs {
@ -59,9 +57,7 @@ impl fmt::Display for ConfError {
ConfError::TypeError(ref key, ref expected, ref got) => {
write!(f, "`{}` is expected to be a `{}` but is a `{}`", key, expected, got)
}
ConfError::UnknownKey(ref key) => {
write!(f, "unknown key `{}`", key)
}
ConfError::UnknownKey(ref key) => write!(f, "unknown key `{}`", key),
}
}
}
@ -177,8 +173,7 @@ pub fn read_conf(path: &str, must_exist: bool) -> Result<Conf, ConfError> {
let mut parser = toml::Parser::new(&file);
let toml = if let Some(toml) = parser.parse() {
toml
}
else {
} else {
return Err(ConfError::TomlError(parser.errors));
};

View File

@ -423,9 +423,7 @@ pub struct TypeComplexityPass {
impl TypeComplexityPass {
pub fn new(threshold: u64) -> Self {
TypeComplexityPass {
threshold: threshold
}
TypeComplexityPass { threshold: threshold }
}
}