diff --git a/src/utils.rs b/src/utils.rs index 195ca265c1fb..aaa838bf043c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -146,7 +146,11 @@ pub fn semicolon_for_stmt(stmt: &ast::Stmt) -> bool { pub fn trim_newlines(input: &str) -> &str { let start = input.find(|c| c != '\n' && c != '\r').unwrap_or(0); let end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0) + 1; - &input[start..end] + if start == 0 && end == 1 { + input + } else { + &input[start..end] + } } #[inline] diff --git a/tests/source/impls.rs b/tests/source/impls.rs index c15ae12325e0..4382c4fd0e61 100644 --- a/tests/source/impls.rs +++ b/tests/source/impls.rs @@ -51,3 +51,10 @@ mod b { } } } + +impl Foo { add_fun!(); } + +impl Blah { + fn boop() {} + add_fun!(); +} diff --git a/tests/target/impls.rs b/tests/target/impls.rs index 972991572a50..35ddc23a20a5 100644 --- a/tests/target/impls.rs +++ b/tests/target/impls.rs @@ -63,3 +63,12 @@ mod b { } } } + +impl Foo { + add_fun!(); +} + +impl Blah { + fn boop() {} + add_fun!(); +}