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
content: "\n// Regression test for #141483\n//@check-pass\n\n#![feature(frontmatter)]\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: "x ---y\n"
424
+
content: "\n// Test that hypens are allowed inside frontmatters if there is some\n// non-whitespace character preceding them.\n//@check-pass\n\n#![feature(frontmatter)]\n\nfn main() {}\n"
425
+
426
+
"#]],
427
+
);
428
+
}
429
+
381
430
#[test]
382
431
fnrustc_frontmatter_non_lexible_tokens(){
383
432
assert_source(
@@ -498,6 +547,80 @@ content: "\n//@ check-pass\n// A frontmatter infostring can have leading whitesp
498
547
);
499
548
}
500
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: None
617
+
frontmatter: None
618
+
content: "#![feature(frontmatter)]\n\n//@ check-pass\n\ninclude!(\"auxiliary/lib.rs\");\n\n// auxiliary/lib.rs contains a frontmatter. Ensure that we can use them in an\n// `include!` macro.\n\nfn main() {\n foo(1);\n}\n"
619
+
620
+
"##]],
621
+
);
622
+
}
623
+
501
624
#[test]
502
625
fnrustc_infostring_fail(){
503
626
// We don't validate infostrings besides `info == "cargo"`
0 commit comments