Merge pull request #2406 from nrc/str-fix
Make `is_mod_decl` more accommodating
This commit is contained in:
commit
ca09746ce9
4 changed files with 5 additions and 8 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -294,7 +294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "rustfmt-nightly"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
dependencies = [
|
||||
"cargo_metadata 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
|
||||
name = "rustfmt-nightly"
|
||||
version = "0.3.7"
|
||||
version = "0.3.8"
|
||||
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
|
||||
description = "Tool to find and fix Rust formatting issues"
|
||||
repository = "https://github.com/rust-lang-nursery/rustfmt"
|
||||
|
|
|
@ -48,8 +48,8 @@ pub trait LineRangeUtils {
|
|||
|
||||
impl SpanUtils for CodeMap {
|
||||
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();
|
||||
let snippet = self.span_to_snippet(original).expect("Bad snippet");
|
||||
let offset = snippet.find_uncommented(needle).expect("Bad offset") + needle.len();
|
||||
|
||||
original.lo() + BytePos(offset as u32)
|
||||
}
|
||||
|
|
|
@ -44,10 +44,7 @@ pub fn filter_inline_attrs(attrs: &[ast::Attribute], outer_span: Span) -> Vec<as
|
|||
/// Returns true for `mod foo;`, false for `mod foo { .. }`.
|
||||
fn is_mod_decl(item: &ast::Item) -> bool {
|
||||
match item.node {
|
||||
ast::ItemKind::Mod(ref m) => {
|
||||
!(m.inner.lo() == BytePos(0) && m.inner.hi() == BytePos(0))
|
||||
&& m.inner.hi() != item.span.hi()
|
||||
}
|
||||
ast::ItemKind::Mod(ref m) => m.inner.hi() != item.span.hi(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue