Skip to content

Commit 60bcd83

Browse files
committed
fix(frontmatter): Be more direct in unclosed error
For comparison, rustc's message is: > error: unclosed frontmatter > --> $DIR/frontmatter-whitespace-2.rs:1:1 > | > LL | / ---cargo > ... | > LL | | > | |_^ > | > note: frontmatter opening here was not closed > --> $DIR/frontmatter-whitespace-2.rs:1:1 > | > LL | ---cargo > | ^^^
1 parent 16d979f commit 60bcd83

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

src/cargo/util/frontmatter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'s> ScriptSource<'s> {
8080
source.open = Some(open_start..open_end);
8181
let Some(info_nl) = input.find_slice("\n") else {
8282
return Err(FrontmatterError::new(
83-
format!("no closing `{fence_pattern}` found for frontmatter"),
83+
format!("unclosed frontmatter; expected `{fence_pattern}`"),
8484
open_start..open_end,
8585
));
8686
};
@@ -109,7 +109,7 @@ impl<'s> ScriptSource<'s> {
109109
));
110110
}
111111
return Err(FrontmatterError::new(
112-
format!("no closing `{fence_pattern}` found for frontmatter"),
112+
format!("unclosed frontmatter; expected `{fence_pattern}`"),
113113
open_start..open_end,
114114
));
115115
};
@@ -636,7 +636,7 @@ time="0.1.25"
636636
fn main() {}
637637
"#,
638638
),
639-
str!["no closing `---` found for frontmatter"],
639+
str!["unclosed frontmatter; expected `---`"],
640640
);
641641
}
642642
}

tests/testsuite/script/rustc_fixtures/frontmatter-whitespace-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `---` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `---`
22
--> script:1:1
33
|
44
1 | ---cargo

tests/testsuite/script/rustc_fixtures/unclosed-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `----` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `----`
22
--> script:1:1
33
|
44
1 | ----cargo

tests/testsuite/script/rustc_fixtures/unclosed-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `----` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `----`
22
--> script:1:1
33
|
44
1 | ----cargo

tests/testsuite/script/rustc_fixtures/unclosed-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `----` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `----`
22
--> script:1:1
33
|
44
1 | ----cargo

tests/testsuite/script/rustc_fixtures/unclosed-4.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `----` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `----`
22
--> script:1:1
33
|
44
1 | ----cargo

tests/testsuite/script/rustc_fixtures/unclosed-5.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ERROR] no closing `----` found for frontmatter
1+
[ERROR] unclosed frontmatter; expected `----`
22
--> script:1:1
33
|
44
1 | ----cargo

0 commit comments

Comments
 (0)