Skip to content

Commit cd77255

Browse files
tests/ui/test-attrs: add annotations for reference rules
1 parent 7057231 commit cd77255

15 files changed

Lines changed: 38 additions & 30 deletions

tests/ui/test-attrs/issue-109816.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --test
2+
//@ reference: attributes.testing.test.allowed-positions
23

34
fn align_offset_weird_strides() {
45
#[test]

tests/ui/test-attrs/issue-109816.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the `#[test]` attribute may only be used on a free function
2-
--> $DIR/issue-109816.rs:4:5
2+
--> $DIR/issue-109816.rs:5:5
33
|
44
LL | #[test]
55
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions

tests/ui/test-attrs/test-attr-non-associated-functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags:--test
2+
//@ reference: attributes.testing.test.allowed-positions
23

34
struct A {}
45

tests/ui/test-attrs/test-attr-non-associated-functions.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the `#[test]` attribute may only be used on a free function
2-
--> $DIR/test-attr-non-associated-functions.rs:6:5
2+
--> $DIR/test-attr-non-associated-functions.rs:7:5
33
|
44
LL | #[test]
55
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -11,7 +11,7 @@ LL + #[cfg(test)]
1111
|
1212

1313
error: the `#[test]` attribute may only be used on a free function
14-
--> $DIR/test-attr-non-associated-functions.rs:11:5
14+
--> $DIR/test-attr-non-associated-functions.rs:12:5
1515
|
1616
LL | #[test]
1717
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions

tests/ui/test-attrs/test-function-signature.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --test
2+
//@ reference: attributes.testing.test.allowed-positions
23

34
#[test]
45
fn foo() -> Result<(), ()> {

tests/ui/test-attrs/test-function-signature.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error: functions used as tests can not have any arguments
2-
--> $DIR/test-function-signature.rs:14:1
2+
--> $DIR/test-function-signature.rs:15:1
33
|
44
LL | fn baz(val: i32) {}
55
| ^^^^^^^^^^^^^^^^^^^
66

77
error: functions used as tests can not have any non-lifetime generic parameters
8-
--> $DIR/test-function-signature.rs:22:1
8+
--> $DIR/test-function-signature.rs:23:1
99
|
1010
LL | fn type_generic<T>() {}
1111
| ^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: functions used as tests can not have any non-lifetime generic parameters
14-
--> $DIR/test-function-signature.rs:25:1
14+
--> $DIR/test-function-signature.rs:26:1
1515
|
1616
LL | fn const_generic<const N: usize>() {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: functions used as tests can not have any arguments
20-
--> $DIR/test-function-signature.rs:30:5
20+
--> $DIR/test-function-signature.rs:31:5
2121
|
2222
LL | fn foo(arg: ()) {}
2323
| ^^^^^^^^^^^^^^^^^^
2424

2525
error[E0277]: the trait bound `i32: Termination` is not satisfied
26-
--> $DIR/test-function-signature.rs:9:13
26+
--> $DIR/test-function-signature.rs:10:13
2727
|
2828
LL | #[test]
2929
| ------- in this attribute macro expansion

tests/ui/test-attrs/test-on-not-fn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --test
2+
//@ reference: attributes.testing.test.allowed-positions
23

34
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
45
mod test {}

tests/ui/test-attrs/test-on-not-fn.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the `#[test]` attribute may only be used on a free function
2-
--> $DIR/test-on-not-fn.rs:3:1
2+
--> $DIR/test-on-not-fn.rs:4:1
33
|
44
LL | #[test]
55
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -13,7 +13,7 @@ LL + #[cfg(test)]
1313
|
1414

1515
error: the `#[test]` attribute may only be used on a free function
16-
--> $DIR/test-on-not-fn.rs:6:1
16+
--> $DIR/test-on-not-fn.rs:7:1
1717
|
1818
LL | #[test]
1919
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -33,7 +33,7 @@ LL + #[cfg(test)]
3333
|
3434

3535
error: the `#[test]` attribute may only be used on a free function
36-
--> $DIR/test-on-not-fn.rs:20:1
36+
--> $DIR/test-on-not-fn.rs:21:1
3737
|
3838
LL | #[test]
3939
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -47,7 +47,7 @@ LL + #[cfg(test)]
4747
|
4848

4949
error: the `#[test]` attribute may only be used on a free function
50-
--> $DIR/test-on-not-fn.rs:23:1
50+
--> $DIR/test-on-not-fn.rs:24:1
5151
|
5252
LL | #[test]
5353
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -61,7 +61,7 @@ LL + #[cfg(test)]
6161
|
6262

6363
error: the `#[test]` attribute may only be used on a free function
64-
--> $DIR/test-on-not-fn.rs:26:1
64+
--> $DIR/test-on-not-fn.rs:27:1
6565
|
6666
LL | #[test]
6767
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -75,7 +75,7 @@ LL + #[cfg(test)]
7575
|
7676

7777
error: the `#[test]` attribute may only be used on a free function
78-
--> $DIR/test-on-not-fn.rs:29:1
78+
--> $DIR/test-on-not-fn.rs:30:1
7979
|
8080
LL | #[test]
8181
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -89,7 +89,7 @@ LL + #[cfg(test)]
8989
|
9090

9191
error: the `#[test]` attribute may only be used on a free function
92-
--> $DIR/test-on-not-fn.rs:32:1
92+
--> $DIR/test-on-not-fn.rs:33:1
9393
|
9494
LL | #[test]
9595
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -103,7 +103,7 @@ LL + #[cfg(test)]
103103
|
104104

105105
error: the `#[test]` attribute may only be used on a free function
106-
--> $DIR/test-on-not-fn.rs:35:1
106+
--> $DIR/test-on-not-fn.rs:36:1
107107
|
108108
LL | #[test]
109109
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -119,7 +119,7 @@ LL + #[cfg(test)]
119119
|
120120

121121
error: the `#[test]` attribute may only be used on a free function
122-
--> $DIR/test-on-not-fn.rs:40:1
122+
--> $DIR/test-on-not-fn.rs:41:1
123123
|
124124
LL | #[test]
125125
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -133,7 +133,7 @@ LL + #[cfg(test)]
133133
|
134134

135135
error: the `#[test]` attribute may only be used on a free function
136-
--> $DIR/test-on-not-fn.rs:43:1
136+
--> $DIR/test-on-not-fn.rs:44:1
137137
|
138138
LL | #[test]
139139
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -150,7 +150,7 @@ LL + #[cfg(test)]
150150
|
151151

152152
error: the `#[test]` attribute may only be used on a free function
153-
--> $DIR/test-on-not-fn.rs:50:1
153+
--> $DIR/test-on-not-fn.rs:51:1
154154
|
155155
LL | #[test]
156156
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
@@ -168,7 +168,7 @@ LL + #[cfg(test)]
168168
|
169169

170170
warning: the `#[test]` attribute may only be used on a free function
171-
--> $DIR/test-on-not-fn.rs:61:1
171+
--> $DIR/test-on-not-fn.rs:62:1
172172
|
173173
LL | #[test]
174174
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions

tests/ui/test-attrs/test-passed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//@ run-pass
55
//@ check-run-results
66
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
7+
//@ reference: attributes.testing.test.intro
78

89
// Tests the output of the test harness with only passed tests.
910

tests/ui/test-attrs/test-should-panic-attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --test
2+
//@ reference: attributes.testing.should_panic.syntax
23

34
#[test]
45
#[should_panic = "foo"]

0 commit comments

Comments
 (0)