You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cargo/util/toml/embedded.rs
+123Lines changed: 123 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -374,6 +374,55 @@ info: None
374
374
frontmatter: None
375
375
content: "#![feature(frontmatter)]\n\n---\n//~^ ERROR: expected item, found `-`\n// FIXME(frontmatter): make this diagnostic better\n---\n\n// frontmatters must be at the start of a file. This test ensures that.\n\nfn main() {}\n"
376
376
377
+
"##]],
378
+
);
379
+
}
380
+
381
+
#[test]
382
+
fnrustc_frontmatter_inner_hyphens_1(){
383
+
assert_source(
384
+
r#"---
385
+
x ---🚧️
386
+
---
387
+
388
+
// Regression test for #141483
389
+
//@check-pass
390
+
391
+
#![feature(frontmatter)]
392
+
393
+
fn main() {}
394
+
"#,
395
+
str![[r##"
396
+
shebang: None
397
+
info: None
398
+
frontmatter: None
399
+
content: "#![feature(frontmatter)]\n\n---\n//~^ ERROR: expected item, found `-`\n// FIXME(frontmatter): make this diagnostic better\n---\n\n// frontmatters must be at the start of a file. This test ensures that.\n\nfn main() {}\n"
400
+
401
+
"##]],
402
+
);
403
+
}
404
+
405
+
#[test]
406
+
fnrustc_frontmatter_inner_hyphens_2(){
407
+
assert_source(
408
+
r#"---
409
+
x ---y
410
+
---
411
+
412
+
// Test that hypens are allowed inside frontmatters if there is some
413
+
// non-whitespace character preceding them.
414
+
//@check-pass
415
+
416
+
#![feature(frontmatter)]
417
+
418
+
fn main() {}
419
+
"#,
420
+
str![[r##"
421
+
shebang: None
422
+
info: None
423
+
frontmatter: None
424
+
content: "#![feature(frontmatter)]\n\n---\n//~^ ERROR: expected item, found `-`\n// FIXME(frontmatter): make this diagnostic better\n---\n\n// frontmatters must be at the start of a file. This test ensures that.\n\nfn main() {}\n"
425
+
377
426
"##]],
378
427
);
379
428
}
@@ -494,6 +543,80 @@ info: "cargo"
494
543
frontmatter: ""
495
544
content: "\n//@ check-pass\n// A frontmatter infostring can have leading whitespace.\n\nfn main() {}\n"
496
545
546
+
"#]],
547
+
);
548
+
}
549
+
550
+
#[test]
551
+
fnrustc_hyphen_in_infostring_leading(){
552
+
// We don't validate infostrings besides `info == "cargo"`
553
+
assert_source(
554
+
r#"--- -toml
555
+
//~^ ERROR: invalid infostring for frontmatter
556
+
---
557
+
558
+
// infostrings cannot have leading hyphens
559
+
560
+
#![feature(frontmatter)]
561
+
562
+
fn main() {}
563
+
"#,
564
+
str![[r#"
565
+
shebang: None
566
+
info: "-toml"
567
+
frontmatter: "//~^ ERROR: invalid infostring for frontmatter\n"
568
+
content: "\n// infostrings cannot have leading hyphens\n\n#![feature(frontmatter)]\n\nfn main() {}\n"
569
+
570
+
"#]],
571
+
);
572
+
}
573
+
574
+
#[test]
575
+
fnrustc_hyphen_in_infostring_non_leading(){
576
+
assert_source(
577
+
r#"--- Cargo-toml
578
+
---
579
+
580
+
// infostrings can contain hyphens as long as a hyphen isn't the first character.
581
+
//@ check-pass
582
+
583
+
#![feature(frontmatter)]
584
+
585
+
fn main() {}
586
+
"#,
587
+
str![[r#"
588
+
shebang: None
589
+
info: "Cargo-toml"
590
+
frontmatter: ""
591
+
content: "\n// infostrings can contain hyphens as long as a hyphen isn't the first character.\n//@ check-pass\n\n#![feature(frontmatter)]\n\nfn main() {}\n"
592
+
593
+
"#]],
594
+
);
595
+
}
596
+
597
+
#[test]
598
+
fnrustc_included_frontmatter(){
599
+
// Deferred to rustc since this requires knowledge of Rust grammar
600
+
assert_source(
601
+
r#"#![feature(frontmatter)]
602
+
603
+
//@ check-pass
604
+
605
+
include!("auxiliary/lib.rs");
606
+
607
+
// auxiliary/lib.rs contains a frontmatter. Ensure that we can use them in an
608
+
// `include!` macro.
609
+
610
+
fn main() {
611
+
foo(1);
612
+
}
613
+
"#,
614
+
str![[r#"
615
+
shebang: None
616
+
info: "Cargo-toml"
617
+
frontmatter: ""
618
+
content: "\n// infostrings can contain hyphens as long as a hyphen isn't the first character.\n//@ check-pass\n\n#![feature(frontmatter)]\n\nfn main() {}\n"
0 commit comments