From 034b73ba54f8221c97f70828d7bd529d64b8fe8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 6 Aug 2024 18:36:43 +0000 Subject: [PATCH] fix test --- compiler/rustc_errors/src/emitter.rs | 8 ++++++++ tests/run-make/crate-loading/rmake.rs | 26 +++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 8df3b685829..88ed3128164 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1365,6 +1365,14 @@ fn emit_messages_default_inner( ); line += 1; } + // We add lines above, but if the last line has no explicit newline (which would + // yield an empty line), then we revert one line up to continue with the next + // styled text chunk on the same line as the last one from the prior one. Otherwise + // every `text` would appear on their own line (because even though they didn't end + // in '\n', they advanced `line` by one). + if line > 0 { + line -= 1; + } } if self.short_message { let labels = msp diff --git a/tests/run-make/crate-loading/rmake.rs b/tests/run-make/crate-loading/rmake.rs index 2aa396fd2d9..fd5b66ae879 100644 --- a/tests/run-make/crate-loading/rmake.rs +++ b/tests/run-make/crate-loading/rmake.rs @@ -13,19 +13,15 @@ fn main() { .input("multiple-dep-versions.rs") .extern_("dependency", rust_lib_name("dependency")) .extern_("dep_2_reexport", rust_lib_name("dependency2")) - .inspect(|cmd| eprintln!("{cmd:?}")) - .run_fail(); - let stderr = out.stderr_utf8(); - assert_contains( - &stderr, - "you have multiple different versions of crate `dependency` in your dependency graph", - ); - assert_contains( - &stderr, - "two types coming from two different versions of the same crate are different types even \ - if they look the same", - ); - assert_contains(&stderr, "this type doesn't implement the required trait"); - assert_contains(&stderr, "this type implements the required trait"); - assert_contains(&stderr, "this is the required trait"); + .run_fail() + .assert_stderr_contains( + "you have multiple different versions of crate `dependency` in your dependency graph", + ) + .assert_stderr_contains( + "two types coming from two different versions of the same crate are different types \ + even if they look the same", + ) + .assert_stderr_contains("this type doesn't implement the required trait") + .assert_stderr_contains("this type implements the required trait") + .assert_stderr_contains("this is the required trait"); }