Skip to content

Commit

Permalink
update Serde, etc.
Browse files Browse the repository at this point in the history
Lots of changes to how closures work
  • Loading branch information
nrc committed Nov 20, 2016
1 parent 61ab06a commit d3eba76
Show file tree
Hide file tree
Showing 19 changed files with 352 additions and 306 deletions.
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ regex = "0.1"
term = "0.4"
strings = "0.0.1"
diff = "0.1"
syntex_syntax = "0.44"
syntex_errors = "0.44"
syntex_syntax = "0.50"
syntex_errors = "0.50"
log = "0.3"
env_logger = "0.3"
getopts = "0.2"
Expand Down
19 changes: 7 additions & 12 deletions src/bin/cargo-fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ fn format_crate(verbosity: Verbosity) -> Result<ExitStatus, std::io::Error> {
// Currently only bin and lib files get formatted
let files: Vec<_> = targets.into_iter()
.filter(|t| t.kind.should_format())
.inspect(|t| {
if verbosity == Verbosity::Verbose {
println!("[{:?}] {:?}", t.kind, t.path)
}
.inspect(|t| if verbosity == Verbosity::Verbose {
println!("[{:?}] {:?}", t.kind, t.path)
})
.map(|t| t.path)
.collect();
Expand Down Expand Up @@ -204,15 +202,12 @@ fn format_files(files: &[PathBuf],
.args(files)
.args(fmt_args)
.spawn()
.map_err(|e| {
match e.kind() {
std::io::ErrorKind::NotFound => {
std::io::Error::new(std::io::ErrorKind::Other,
"Could not run rustfmt, please make sure it is in your \
PATH.")
}
_ => e,
.map_err(|e| match e.kind() {
std::io::ErrorKind::NotFound => {
std::io::Error::new(std::io::ErrorKind::Other,
"Could not run rustfmt, please make sure it is in your PATH.")
}
_ => e,
}));
command.wait()
}
3 changes: 0 additions & 3 deletions src/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ pub trait LineRangeUtils {
}

impl SpanUtils for CodeMap {
#[inline]
fn span_after(&self, original: Span, needle: &str) -> BytePos {
let snippet = self.span_to_snippet(original).unwrap();
let offset = snippet.find_uncommented(needle).unwrap() + needle.len();

original.lo + BytePos(offset as u32)
}

#[inline]
fn span_after_last(&self, original: Span, needle: &str) -> BytePos {
let snippet = self.span_to_snippet(original).unwrap();
let mut offset = 0;
Expand All @@ -66,7 +64,6 @@ impl SpanUtils for CodeMap {
original.lo + BytePos(offset as u32)
}

#[inline]
fn span_before(&self, original: Span, needle: &str) -> BytePos {
let snippet = self.span_to_snippet(original).unwrap();
let offset = snippet.find_uncommented(needle).unwrap();
Expand Down
18 changes: 7 additions & 11 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ pub fn rewrite_comment(orig: &str,
line.trim_right()
})
.map(left_trim_comment_line)
.map(|line| {
if orig.starts_with("/*") && line_breaks == 0 {
line.trim_left()
} else {
line
}
.map(|line| if orig.starts_with("/*") && line_breaks == 0 {
line.trim_left()
} else {
line
});

let mut result = opener.to_owned();
Expand Down Expand Up @@ -746,11 +744,9 @@ mod test {
// keeping it around unless it helps us test stuff.
fn uncommented(text: &str) -> String {
CharClasses::new(text.chars())
.filter_map(|(s, c)| {
match s {
FullCodeCharKind::Normal => Some(c),
_ => None,
}
.filter_map(|(s, c)| match s {
FullCodeCharKind::Normal => Some(c),
_ => None,
})
.collect()
}
Expand Down
Loading

0 comments on commit d3eba76

Please sign in to comment.