Skip to content

Commit 229385b

Browse files
committed
fix(toml): Remove dashed and hashed frontmatter syntax
1 parent 5c3bc8d commit 229385b

File tree

2 files changed

+11
-86
lines changed

2 files changed

+11
-86
lines changed

src/cargo/util/toml/embedded.rs

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,7 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
218218
}
219219

220220
// Experiment: let us try which char works better
221-
let tick_char = source
222-
.content
223-
.chars()
224-
.filter(|c| ['`', '#', '-'].contains(c))
225-
.next()
226-
.unwrap_or('`');
221+
let tick_char = '-';
227222

228223
let tick_end = source
229224
.content
@@ -235,10 +230,6 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
235230
return Ok(source);
236231
}
237232
1 | 2 => {
238-
if tick_char == '#' {
239-
// Attribute
240-
return Ok(source);
241-
}
242233
anyhow::bail!("found {tick_end} `{tick_char}` in rust frontmatter, expected at least 3")
243234
}
244235
_ => source.content.split_at(tick_end),
@@ -332,10 +323,10 @@ strip = true
332323
333324
[workspace]
334325
"#,
335-
si!(r#"```cargo
326+
si!(r#"---cargo
336327
[dependencies]
337328
time="0.1.25"
338-
```
329+
---
339330
fn main() {}
340331
"#),
341332
);
@@ -363,79 +354,13 @@ name = "test-"
363354
[profile.release]
364355
strip = true
365356
366-
[workspace]
367-
"#,
368-
si!(r#"```
369-
[dependencies]
370-
time="0.1.25"
371-
```
372-
fn main() {}
373-
"#),
374-
);
375-
}
376-
377-
#[test]
378-
fn test_dash() {
379-
snapbox::assert_matches(
380-
r#"[[bin]]
381-
name = "test-"
382-
path = [..]
383-
384-
[dependencies]
385-
time = "0.1.25"
386-
387-
[package]
388-
autobenches = false
389-
autobins = false
390-
autoexamples = false
391-
autotests = false
392-
build = false
393-
edition = "2021"
394-
name = "test-"
395-
396-
[profile.release]
397-
strip = true
398-
399357
[workspace]
400358
"#,
401359
si!(r#"---
402360
[dependencies]
403361
time="0.1.25"
404362
---
405363
fn main() {}
406-
"#),
407-
);
408-
}
409-
410-
#[test]
411-
fn test_hash() {
412-
snapbox::assert_matches(
413-
r#"[[bin]]
414-
name = "test-"
415-
path = [..]
416-
417-
[dependencies]
418-
time = "0.1.25"
419-
420-
[package]
421-
autobenches = false
422-
autobins = false
423-
autoexamples = false
424-
autotests = false
425-
build = false
426-
edition = "2021"
427-
name = "test-"
428-
429-
[profile.release]
430-
strip = true
431-
432-
[workspace]
433-
"#,
434-
si!(r#"###
435-
[dependencies]
436-
time="0.1.25"
437-
###
438-
fn main() {}
439364
"#),
440365
);
441366
}

tests/testsuite/script.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ fn requires_z_flag() {
210210
#[cargo_test]
211211
fn clean_output_with_edition() {
212212
let script = r#"#!/usr/bin/env cargo
213-
```cargo
213+
---
214214
[package]
215215
edition = "2018"
216-
```
216+
---
217217
218218
fn main() {
219219
println!("Hello world!");
@@ -241,9 +241,9 @@ fn main() {
241241
#[cargo_test]
242242
fn warning_without_edition() {
243243
let script = r#"#!/usr/bin/env cargo
244-
```cargo
244+
---
245245
[package]
246-
```
246+
---
247247
248248
fn main() {
249249
println!("Hello world!");
@@ -714,10 +714,10 @@ fn did_you_mean_command_stable() {
714714
fn test_name_same_as_dependency() {
715715
Package::new("script", "1.0.0").publish();
716716
let script = r#"#!/usr/bin/env cargo
717-
```cargo
717+
---
718718
[dependencies]
719719
script = "1.0.0"
720-
```
720+
---
721721
722722
fn main() {
723723
println!("Hello world!");
@@ -751,10 +751,10 @@ fn main() {
751751
#[cargo_test]
752752
fn test_path_dep() {
753753
let script = r#"#!/usr/bin/env cargo
754-
```cargo
754+
---
755755
[dependencies]
756756
bar.path = "./bar"
757-
```
757+
---
758758
759759
fn main() {
760760
println!("Hello world!");

0 commit comments

Comments
 (0)