From b6326d3255283f0fe353b8c85446e371634f5c36 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 16 Sep 2025 11:10:32 -0500 Subject: [PATCH] fix(frontmatter): Have too few error match too many on close --- src/cargo/util/frontmatter.rs | 5 ++++- tests/testsuite/script/rustc_fixtures/mismatch-2.stderr | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cargo/util/frontmatter.rs b/src/cargo/util/frontmatter.rs index 50b5b5846..c3a7a33d2 100644 --- a/src/cargo/util/frontmatter.rs +++ b/src/cargo/util/frontmatter.rs @@ -103,8 +103,11 @@ impl<'s> ScriptSource<'s> { let close_start = input.current_token_start(); let _ = input.next_slice(len); let close_end = input.current_token_start(); + let fewer_dashes = fence_length - len; return Err(FrontmatterError::new( - format!("closing code fence has too few `-`"), + format!( + "closing code fence has {fewer_dashes} less `-` than the opening fence" + ), close_start..close_end, )); } diff --git a/tests/testsuite/script/rustc_fixtures/mismatch-2.stderr b/tests/testsuite/script/rustc_fixtures/mismatch-2.stderr index 48667df6a..654641433 100644 --- a/tests/testsuite/script/rustc_fixtures/mismatch-2.stderr +++ b/tests/testsuite/script/rustc_fixtures/mismatch-2.stderr @@ -1,4 +1,4 @@ -[ERROR] closing code fence has too few `-` +[ERROR] closing code fence has 1 less `-` than the opening fence --> script:3:1 | 3 | ---cargo