Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that we don't use any unstable features. #560

Merged
merged 3 commits into from Mar 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
simplify errors
  • Loading branch information
steveklabnik committed Mar 23, 2017
commit 3207d5d4a2800216ddcddeac954179dc65175662
@@ -1,3 +1,4 @@
use std::error::Error;
use std::env;
use std::fmt;
use std::fs;
@@ -22,33 +23,7 @@ fn main() {

}

enum Error {
Io(io::Error),
LintFailure(String),
}

impl From<io::Error> for Error {
fn from(e: io::Error) -> Error {
Error::Io(e)
}
}

impl From<String> for Error {
fn from(e: String) -> Error {
Error::LintFailure(e)
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&Error::Io(ref e) => write!(f, "I/O error: {}", e),
&Error::LintFailure(ref e) => write!(f, "Lint failed: {}", e),
}
}
}

fn check_directory(dir: &Path) -> Result<(), Error> {
fn check_directory(dir: &Path) -> Result<(), Box<Error>> {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
@@ -62,7 +37,7 @@ fn check_directory(dir: &Path) -> Result<(), Error> {
file.read_to_string(&mut contents)?;

if contents.contains("#![feature") {
return Err(Error::LintFailure(format!("Feature flag found in {:?}", path)));
return Err(From::from(format!("Feature flag found in {:?}", path)));
}
}