Skip to content

Commit 512ebed

Browse files
committed
add more -Z crate-attr tests
1 parent 6e83ebe commit 512ebed

17 files changed

+108
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Ensure that `-Z crate-attr=cfg(FALSE)` can comment out the whole crate
2+
//@ compile-flags: --crate-type=lib -Zcrate-attr=cfg(FALSE)
3+
//@ check-pass
4+
5+
// NOTE: duplicate items are load-bearing
6+
fn foo() {}
7+
fn foo() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ check-pass
2+
//@ compile-flags: -Zcrate-attr=/*hi-there*/feature(rustc_attrs)
3+
4+
#[rustc_dummy]
5+
fn main() {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Ensure that `crate_name` and `crate_type` can be set through `-Z crate-attr`.
2+
//@ check-pass
3+
//@ compile-flags: -Zcrate-attr=crate_name="override"
4+
fn main() {
5+
assert_eq!(module_path!(), "r#override");
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//@ check-pass
2+
//@ compile-flags: -Zcrate-attr=crate_type="lib"
3+
// notice the lack of `main` is load-bearing
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Show diagnostics for invalid tokens
2+
//@ compile-flags: -Zcrate-attr=`%~@$#
3+
//@ error-pattern:unknown start of token
4+
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: unknown start of token: `
2+
--> <crate attribute>:1:1
3+
|
4+
LL | `%~@$#
5+
| ^
6+
|
7+
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
8+
|
9+
LL - `%~@$#
10+
LL + '%~@$#
11+
|
12+
13+
error: expected identifier, found `%`
14+
--> <crate attribute>:1:2
15+
|
16+
LL | `%~@$#
17+
| ^ expected identifier
18+
19+
error: aborting due to 2 previous errors
20+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//@ compile-flags: '-Zcrate-attr=feature(yeet_expr)]fn main(){}#[inline'
2+
//@ error-pattern:unexpected closing delimiter
3+
fn foo() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: unexpected closing delimiter: `]`
2+
--> <crate attribute>:1:19
3+
|
4+
LL | feature(yeet_expr)]fn main(){}#[inline
5+
| ^ unexpected closing delimiter
6+
7+
error: aborting due to 1 previous error
8+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ compile-flags: -Zcrate-attr=#![feature(foo)]
2+
//@ error-pattern:expected identifier
3+
4+
fn main() {}

0 commit comments

Comments
 (0)