Skip to content

Commit dce3ea2

Browse files
committed
Add preliminary test for raw-idents in cfgs
1 parent b91f02e commit dce3ea2

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

tests/testsuite/cfg.rs

+90
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,96 @@ error[E0463]: can't find crate for `bar`
522522
.run();
523523
}
524524

525+
#[cargo_test]
526+
fn cfg_raw_idents() {
527+
let p = project()
528+
.file(
529+
"Cargo.toml",
530+
r#"
531+
[package]
532+
name = "foo"
533+
version = "0.1.0"
534+
edition = "2015"
535+
536+
[target.'cfg(any(r#fn, r#all, r#target_os = "<>"))'.dependencies]
537+
b = { path = "b/" }
538+
"#,
539+
)
540+
.file("src/lib.rs", "")
541+
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1"))
542+
.file("b/src/lib.rs", "pub fn foo() {}")
543+
.build();
544+
545+
p.cargo("check")
546+
.with_status(101)
547+
.with_stderr_data(str![[r#"
548+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
549+
550+
Caused by:
551+
failed to parse `any(r#fn, r#all, r#target_os = "<>")` as a cfg expression: unexpected character `#` in cfg, expected parens, a comma, an identifier, or a string
552+
553+
"#]])
554+
.run();
555+
}
556+
557+
#[cargo_test]
558+
fn cfg_raw_idents_empty() {
559+
let p = project()
560+
.file(
561+
"Cargo.toml",
562+
r#"
563+
[package]
564+
name = "foo"
565+
version = "0.1.0"
566+
edition = "2015"
567+
568+
[target.'cfg(r#))'.dependencies]
569+
"#,
570+
)
571+
.file("src/lib.rs", "")
572+
.build();
573+
574+
p.cargo("check")
575+
.with_status(101)
576+
.with_stderr_data(str![[r#"
577+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
578+
579+
Caused by:
580+
failed to parse `r#)` as a cfg expression: unexpected content `#)` found after cfg expression
581+
582+
"#]])
583+
.run();
584+
}
585+
586+
#[cargo_test]
587+
fn cfg_raw_idents_not_really() {
588+
let p = project()
589+
.file(
590+
"Cargo.toml",
591+
r#"
592+
[package]
593+
name = "foo"
594+
version = "0.1.0"
595+
edition = "2015"
596+
597+
[target.'cfg(r#11))'.dependencies]
598+
"#,
599+
)
600+
.file("src/lib.rs", "")
601+
.build();
602+
603+
p.cargo("check")
604+
.with_status(101)
605+
.with_stderr_data(str![[r#"
606+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
607+
608+
Caused by:
609+
failed to parse `r#11)` as a cfg expression: unexpected content `#11)` found after cfg expression
610+
611+
"#]])
612+
.run();
613+
}
614+
525615
#[cargo_test]
526616
fn cfg_keywords() {
527617
let p = project()

0 commit comments

Comments
 (0)