diff --git a/src/liballoc/tests/cow_str.rs b/src/liballoc/tests/cow_str.rs index aa87ee84b3e97..63939686ab7c2 100644 --- a/src/liballoc/tests/cow_str.rs +++ b/src/liballoc/tests/cow_str.rs @@ -148,4 +148,4 @@ fn check_cow_clone_from() { let c2: Cow = Cow::Owned(s); c1.clone_from(&c2); assert!(c1.into_owned().capacity() >= 25); -} \ No newline at end of file +} diff --git a/src/libcore/tests/ops.rs b/src/libcore/tests/ops.rs index b81b3878c9d6e..9d2fa1abff658 100644 --- a/src/libcore/tests/ops.rs +++ b/src/libcore/tests/ops.rs @@ -67,4 +67,4 @@ fn test_range_inclusive() { r = RangeInclusive { start: 1, end: -1 }; assert_eq!(r.size_hint(), (0, Some(0))); assert_eq!(r.next(), None); -} \ No newline at end of file +} diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs index de7eebe7bf3fb..3a05cb7187d80 100644 --- a/src/libserialize/collection_impls.rs +++ b/src/libserialize/collection_impls.rs @@ -241,4 +241,4 @@ impl Decodable for Arc<[T]> { Ok(vec.into()) }) } -} \ No newline at end of file +} diff --git a/src/test/codegen/prefetch.rs b/src/test/codegen/prefetch.rs index 9ca2f01f80d7d..3a23c16d5214d 100644 --- a/src/test/codegen/prefetch.rs +++ b/src/test/codegen/prefetch.rs @@ -71,5 +71,3 @@ pub fn check_prefetch_write_instruction(data: &[i8]) { prefetch_write_instruction(data.as_ptr(), 3); } } - - diff --git a/src/test/compile-fail/E0004.rs b/src/test/compile-fail/E0004.rs index 79e53c7a29fdb..8df07a0c1c5b2 100644 --- a/src/test/compile-fail/E0004.rs +++ b/src/test/compile-fail/E0004.rs @@ -19,4 +19,4 @@ fn main() { match x { //~ ERROR E0004 Terminator::TalkToMyHand => {} } -} \ No newline at end of file +} diff --git a/src/test/compile-fail/duplicate_entry_error.rs b/src/test/compile-fail/duplicate_entry_error.rs index ad5ea29159968..485519e8c3d7e 100644 --- a/src/test/compile-fail/duplicate_entry_error.rs +++ b/src/test/compile-fail/duplicate_entry_error.rs @@ -20,4 +20,4 @@ fn panic_fmt() -> ! { loop {} } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/float-int-invalid-const-cast.rs b/src/test/compile-fail/float-int-invalid-const-cast.rs index 2efefd926919f..1f07422e21be4 100644 --- a/src/test/compile-fail/float-int-invalid-const-cast.rs +++ b/src/test/compile-fail/float-int-invalid-const-cast.rs @@ -58,4 +58,4 @@ fn main() { { const X: u32 = 4294967296. as u32; force(X); } //~ ERROR constant evaluation error { const X: u128 = 1e40 as u128; force(X); } //~ ERROR constant evaluation error { const X: i128 = 1e40 as i128; force(X); } //~ ERROR constant evaluation error -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-28848.rs b/src/test/compile-fail/issue-28848.rs index 3d23ce0ee4e61..1a06d59f0b191 100644 --- a/src/test/compile-fail/issue-28848.rs +++ b/src/test/compile-fail/issue-28848.rs @@ -20,4 +20,4 @@ pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/never-assign-wrong-type.rs b/src/test/compile-fail/never-assign-wrong-type.rs index d854e6eb20388..c0dd2cab749f4 100644 --- a/src/test/compile-fail/never-assign-wrong-type.rs +++ b/src/test/compile-fail/never-assign-wrong-type.rs @@ -16,5 +16,3 @@ fn main() { let x: ! = "hello"; //~ ERROR mismatched types } - - diff --git a/src/test/compile-fail/range_inclusive_gate.rs b/src/test/compile-fail/range_inclusive_gate.rs index 69b9a4c67adc3..5b063dc1137c0 100644 --- a/src/test/compile-fail/range_inclusive_gate.rs +++ b/src/test/compile-fail/range_inclusive_gate.rs @@ -19,5 +19,3 @@ pub fn main() { //~| ERROR core_intrinsics //~| ERROR core_intrinsics } - - diff --git a/src/test/compile-fail/useless_comment.rs b/src/test/compile-fail/useless_comment.rs index a1172bb214d0a..90eb66728fce5 100644 --- a/src/test/compile-fail/useless_comment.rs +++ b/src/test/compile-fail/useless_comment.rs @@ -27,4 +27,4 @@ fn foo() { fn main() { foo(); -} \ No newline at end of file +} diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index 02746785856cc..36cbd2239a052 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -651,5 +651,3 @@ mod change_trait_bound_indirectly_where { Variant1(T) } } - - diff --git a/src/test/incremental/hashes/inline_asm.rs b/src/test/incremental/hashes/inline_asm.rs index b93a96566031c..3996e92e05a91 100644 --- a/src/test/incremental/hashes/inline_asm.rs +++ b/src/test/incremental/hashes/inline_asm.rs @@ -236,6 +236,3 @@ pub fn change_options(_a: i32) -> i32 { } _out } - - - diff --git a/src/test/mir-opt/return_an_array.rs b/src/test/mir-opt/return_an_array.rs index 4409f16b3f5ff..bfae5b9438970 100644 --- a/src/test/mir-opt/return_an_array.rs +++ b/src/test/mir-opt/return_an_array.rs @@ -15,4 +15,4 @@ fn foo() -> [u8; 1024] { return x; } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/parse-fail/issue-37113.rs b/src/test/parse-fail/issue-37113.rs index caf451099d714..14c6f3944bb59 100644 --- a/src/test/parse-fail/issue-37113.rs +++ b/src/test/parse-fail/issue-37113.rs @@ -18,4 +18,4 @@ macro_rules! test_macro { fn main() { test_macro!(String,); -} \ No newline at end of file +} diff --git a/src/test/parse-fail/range_inclusive_gate.rs b/src/test/parse-fail/range_inclusive_gate.rs index de690c3fea3cf..6b6afc504e150 100644 --- a/src/test/parse-fail/range_inclusive_gate.rs +++ b/src/test/parse-fail/range_inclusive_gate.rs @@ -72,5 +72,3 @@ pub fn main() { o!(); // not allowed in macros that output cfgs p!(); // not allowed in cfg'ed macros that output cfgs } - - diff --git a/src/test/run-fail/return-never-coerce.rs b/src/test/run-fail/return-never-coerce.rs index 4cd93ac7e1a5d..ddcecd97ba596 100644 --- a/src/test/run-fail/return-never-coerce.rs +++ b/src/test/run-fail/return-never-coerce.rs @@ -24,5 +24,3 @@ fn main() { let x: i32 = call_another_fn(wub); let y: u32 = wub(); } - - diff --git a/src/test/run-make/a-b-a-linker-guard/a.rs b/src/test/run-make/a-b-a-linker-guard/a.rs index e6cbe2e64d0e9..c6680a78819db 100644 --- a/src/test/run-make/a-b-a-linker-guard/a.rs +++ b/src/test/run-make/a-b-a-linker-guard/a.rs @@ -16,5 +16,3 @@ pub fn foo(x: u32) { } #[cfg(y)] pub fn foo(x: i32) { } - - diff --git a/src/test/run-make/reproducible-build/reproducible-build.rs b/src/test/run-make/reproducible-build/reproducible-build.rs index dc7c702e5cc67..b47d780e52984 100644 --- a/src/test/run-make/reproducible-build/reproducible-build.rs +++ b/src/test/run-make/reproducible-build/reproducible-build.rs @@ -124,5 +124,3 @@ fn main() { TupleStruct(1, 2, 3, 4).bar(); } - - diff --git a/src/test/run-pass/abi-sysv64-register-usage.rs b/src/test/run-pass/abi-sysv64-register-usage.rs index 1cae86712668b..e701329127502 100644 --- a/src/test/run-pass/abi-sysv64-register-usage.rs +++ b/src/test/run-pass/abi-sysv64-register-usage.rs @@ -102,4 +102,4 @@ pub fn main() { } #[cfg(not(target_arch = "x86_64"))] -pub fn main() {} \ No newline at end of file +pub fn main() {} diff --git a/src/test/run-pass/auxiliary/issue_42007_s.rs b/src/test/run-pass/auxiliary/issue_42007_s.rs index b965e916f98f0..91ad9869ed856 100644 --- a/src/test/run-pass/auxiliary/issue_42007_s.rs +++ b/src/test/run-pass/auxiliary/issue_42007_s.rs @@ -11,4 +11,4 @@ #[repr(u8)] pub enum E { B = 1 as u8, -} \ No newline at end of file +} diff --git a/src/test/run-pass/for-loop-mut-ref-element.rs b/src/test/run-pass/for-loop-mut-ref-element.rs index 14ce23b07242c..556c846b0b8e1 100644 --- a/src/test/run-pass/for-loop-mut-ref-element.rs +++ b/src/test/run-pass/for-loop-mut-ref-element.rs @@ -12,4 +12,4 @@ fn main() { for ref mut _a in std::iter::once(true) {} -} \ No newline at end of file +} diff --git a/src/test/run-pass/generator/borrow-in-tail-expr.rs b/src/test/run-pass/generator/borrow-in-tail-expr.rs index df1a1dcebe606..486fe3c900d8b 100644 --- a/src/test/run-pass/generator/borrow-in-tail-expr.rs +++ b/src/test/run-pass/generator/borrow-in-tail-expr.rs @@ -16,4 +16,4 @@ fn main() { let a = String::new(); a.len() }; -} \ No newline at end of file +} diff --git a/src/test/run-pass/generator/match-bindings.rs b/src/test/run-pass/generator/match-bindings.rs index 9c6b0571e58c5..231aa1b42f021 100644 --- a/src/test/run-pass/generator/match-bindings.rs +++ b/src/test/run-pass/generator/match-bindings.rs @@ -27,4 +27,4 @@ fn main() { yield; } }; -} \ No newline at end of file +} diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index 5ff070f311e01..5ea4b1fe93c80 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -20,4 +20,4 @@ fn bar<'a>() { }; } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/issue-22066.rs b/src/test/run-pass/issue-22066.rs index 2817ef77108b0..c2486f0dcb498 100644 --- a/src/test/run-pass/issue-22066.rs +++ b/src/test/run-pass/issue-22066.rs @@ -18,4 +18,4 @@ pub trait LineFormatter<'a> { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/issue-32292.rs b/src/test/run-pass/issue-32292.rs index 3995caa32bf17..ed319b1391dc3 100644 --- a/src/test/run-pass/issue-32292.rs +++ b/src/test/run-pass/issue-32292.rs @@ -15,4 +15,4 @@ struct Foo; fn main() { let _ = Foo; -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-33992.rs b/src/test/run-pass/issue-33992.rs index 5729469f69754..98da7d46b1aa3 100644 --- a/src/test/run-pass/issue-33992.rs +++ b/src/test/run-pass/issue-33992.rs @@ -37,4 +37,4 @@ pub static TEST7: bool = true; #[linkage = "weak_odr"] pub static TEST8: bool = true; -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/issue-35376.rs b/src/test/run-pass/issue-35376.rs index 25895cd0753e4..9e4eb84edc67c 100644 --- a/src/test/run-pass/issue-35376.rs +++ b/src/test/run-pass/issue-35376.rs @@ -48,4 +48,4 @@ pub struct Handle; impl Beta for Handle { type Event = (); -} \ No newline at end of file +} diff --git a/src/test/run-pass/optimization-fuel-1.rs b/src/test/run-pass/optimization-fuel-1.rs index 5f294e26aa53e..e3529ebfb0d81 100644 --- a/src/test/run-pass/optimization-fuel-1.rs +++ b/src/test/run-pass/optimization-fuel-1.rs @@ -22,5 +22,3 @@ fn main() { +(size_of::() == 4) as usize; assert_eq!(optimized, 1); } - - diff --git a/src/test/rustdoc/doc-cfg.rs b/src/test/rustdoc/doc-cfg.rs index cfb37912fe757..8499e5c741ee0 100644 --- a/src/test/rustdoc/doc-cfg.rs +++ b/src/test/rustdoc/doc-cfg.rs @@ -44,4 +44,4 @@ pub mod unix_only { impl ArmOnly for super::Portable { fn unix_and_arm_only_function() {} } -} \ No newline at end of file +} diff --git a/src/test/ui-fulldeps/update-references.sh b/src/test/ui-fulldeps/update-references.sh index b9ded7d1e951c..c2c842fcc4984 100644 --- a/src/test/ui-fulldeps/update-references.sh +++ b/src/test/ui-fulldeps/update-references.sh @@ -46,5 +46,3 @@ while [[ "$1" != "" ]]; do cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME fi done - - diff --git a/src/test/ui/in-band-lifetimes/single_use_lifetimes-4.rs b/src/test/ui/in-band-lifetimes/single_use_lifetimes-4.rs index ead987a09ab97..4ac8f8c0d4e22 100644 --- a/src/test/ui/in-band-lifetimes/single_use_lifetimes-4.rs +++ b/src/test/ui/in-band-lifetimes/single_use_lifetimes-4.rs @@ -17,4 +17,4 @@ enum Bar<'x> { //~ ERROR lifetime name `'x` only used once Variant(&'x u32) } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/ui/in-band-lifetimes/single_use_lifetimes.rs b/src/test/ui/in-band-lifetimes/single_use_lifetimes.rs index 96aaf8923f140..a97056b6240ec 100644 --- a/src/test/ui/in-band-lifetimes/single_use_lifetimes.rs +++ b/src/test/ui/in-band-lifetimes/single_use_lifetimes.rs @@ -13,4 +13,4 @@ fn deref<'x>(v: &'x u32) -> u32 { //~ ERROR lifetime name `'x` only used once *v } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/ui/update-references.sh b/src/test/ui/update-references.sh index b9ded7d1e951c..c2c842fcc4984 100755 --- a/src/test/ui/update-references.sh +++ b/src/test/ui/update-references.sh @@ -46,5 +46,3 @@ while [[ "$1" != "" ]]; do cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME fi done - - diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 40d84b98d3a7d..b784a0e4c5fa0 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -130,6 +130,7 @@ pub fn check(path: &Path, bad: &mut bool) { let skip_tab = contents.contains("ignore-tidy-tab"); let skip_length = contents.contains("ignore-tidy-linelength"); let skip_end_whitespace = contents.contains("ignore-tidy-end-whitespace"); + let mut trailing_new_lines = 0; for (i, line) in contents.split("\n").enumerate() { let mut err = |msg: &str| { tidy_error!(bad, "{}:{}: {}", file.display(), i + 1, msg); @@ -161,10 +162,20 @@ pub fn check(path: &Path, bad: &mut bool) { if filename.ends_with(".cpp") && line.contains("llvm_unreachable") { err(LLVM_UNREACHABLE_INFO); } + if line.is_empty() { + trailing_new_lines += 1; + } else { + trailing_new_lines = 0; + } } if !licenseck(file, &contents) { tidy_error!(bad, "{}: incorrect license", file.display()); } + match trailing_new_lines { + 0 => tidy_error!(bad, "{}: missing trailing newline", file.display()), + 1 | 2 => {} + n => tidy_error!(bad, "{}: too many trailing newlines ({})", file.display(), n), + }; }) }