mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
fix(toml): Remove dashed and hashed frontmatter syntax
This commit is contained in:
parent
5c3bc8d0e1
commit
229385bcc8
@ -218,12 +218,7 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Experiment: let us try which char works better
|
// Experiment: let us try which char works better
|
||||||
let tick_char = source
|
let tick_char = '-';
|
||||||
.content
|
|
||||||
.chars()
|
|
||||||
.filter(|c| ['`', '#', '-'].contains(c))
|
|
||||||
.next()
|
|
||||||
.unwrap_or('`');
|
|
||||||
|
|
||||||
let tick_end = source
|
let tick_end = source
|
||||||
.content
|
.content
|
||||||
@ -235,10 +230,6 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
|
|||||||
return Ok(source);
|
return Ok(source);
|
||||||
}
|
}
|
||||||
1 | 2 => {
|
1 | 2 => {
|
||||||
if tick_char == '#' {
|
|
||||||
// Attribute
|
|
||||||
return Ok(source);
|
|
||||||
}
|
|
||||||
anyhow::bail!("found {tick_end} `{tick_char}` in rust frontmatter, expected at least 3")
|
anyhow::bail!("found {tick_end} `{tick_char}` in rust frontmatter, expected at least 3")
|
||||||
}
|
}
|
||||||
_ => source.content.split_at(tick_end),
|
_ => source.content.split_at(tick_end),
|
||||||
@ -332,10 +323,10 @@ strip = true
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
"#,
|
"#,
|
||||||
si!(r#"```cargo
|
si!(r#"---cargo
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time="0.1.25"
|
time="0.1.25"
|
||||||
```
|
---
|
||||||
fn main() {}
|
fn main() {}
|
||||||
"#),
|
"#),
|
||||||
);
|
);
|
||||||
@ -363,39 +354,6 @@ name = "test-"
|
|||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
[workspace]
|
|
||||||
"#,
|
|
||||||
si!(r#"```
|
|
||||||
[dependencies]
|
|
||||||
time="0.1.25"
|
|
||||||
```
|
|
||||||
fn main() {}
|
|
||||||
"#),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_dash() {
|
|
||||||
snapbox::assert_matches(
|
|
||||||
r#"[[bin]]
|
|
||||||
name = "test-"
|
|
||||||
path = [..]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
time = "0.1.25"
|
|
||||||
|
|
||||||
[package]
|
|
||||||
autobenches = false
|
|
||||||
autobins = false
|
|
||||||
autoexamples = false
|
|
||||||
autotests = false
|
|
||||||
build = false
|
|
||||||
edition = "2021"
|
|
||||||
name = "test-"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
strip = true
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
"#,
|
"#,
|
||||||
si!(r#"---
|
si!(r#"---
|
||||||
@ -403,39 +361,6 @@ strip = true
|
|||||||
time="0.1.25"
|
time="0.1.25"
|
||||||
---
|
---
|
||||||
fn main() {}
|
fn main() {}
|
||||||
"#),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_hash() {
|
|
||||||
snapbox::assert_matches(
|
|
||||||
r#"[[bin]]
|
|
||||||
name = "test-"
|
|
||||||
path = [..]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
time = "0.1.25"
|
|
||||||
|
|
||||||
[package]
|
|
||||||
autobenches = false
|
|
||||||
autobins = false
|
|
||||||
autoexamples = false
|
|
||||||
autotests = false
|
|
||||||
build = false
|
|
||||||
edition = "2021"
|
|
||||||
name = "test-"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
strip = true
|
|
||||||
|
|
||||||
[workspace]
|
|
||||||
"#,
|
|
||||||
si!(r#"###
|
|
||||||
[dependencies]
|
|
||||||
time="0.1.25"
|
|
||||||
###
|
|
||||||
fn main() {}
|
|
||||||
"#),
|
"#),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -210,10 +210,10 @@ fn requires_z_flag() {
|
|||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn clean_output_with_edition() {
|
fn clean_output_with_edition() {
|
||||||
let script = r#"#!/usr/bin/env cargo
|
let script = r#"#!/usr/bin/env cargo
|
||||||
```cargo
|
---
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
```
|
---
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello world!");
|
println!("Hello world!");
|
||||||
@ -241,9 +241,9 @@ fn main() {
|
|||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn warning_without_edition() {
|
fn warning_without_edition() {
|
||||||
let script = r#"#!/usr/bin/env cargo
|
let script = r#"#!/usr/bin/env cargo
|
||||||
```cargo
|
---
|
||||||
[package]
|
[package]
|
||||||
```
|
---
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello world!");
|
println!("Hello world!");
|
||||||
@ -714,10 +714,10 @@ fn did_you_mean_command_stable() {
|
|||||||
fn test_name_same_as_dependency() {
|
fn test_name_same_as_dependency() {
|
||||||
Package::new("script", "1.0.0").publish();
|
Package::new("script", "1.0.0").publish();
|
||||||
let script = r#"#!/usr/bin/env cargo
|
let script = r#"#!/usr/bin/env cargo
|
||||||
```cargo
|
---
|
||||||
[dependencies]
|
[dependencies]
|
||||||
script = "1.0.0"
|
script = "1.0.0"
|
||||||
```
|
---
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello world!");
|
println!("Hello world!");
|
||||||
@ -751,10 +751,10 @@ fn main() {
|
|||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn test_path_dep() {
|
fn test_path_dep() {
|
||||||
let script = r#"#!/usr/bin/env cargo
|
let script = r#"#!/usr/bin/env cargo
|
||||||
```cargo
|
---
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bar.path = "./bar"
|
bar.path = "./bar"
|
||||||
```
|
---
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello world!");
|
println!("Hello world!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user