@@ -41,20 +41,23 @@ Update the file with some examples to get started:
41
41
struct A;
42
42
impl A {
43
43
pub fn fo(&self) {}
44
- pub fn foo(&self) {} //~ ERROR: function called "foo"
44
+ pub fn foo(&self) {}
45
+ //~^ foo_functions
45
46
pub fn food(&self) {}
46
47
}
47
48
48
49
// Default trait methods
49
50
trait B {
50
51
fn fo(&self) {}
51
- fn foo(&self) {} //~ ERROR: function called "foo"
52
+ fn foo(&self) {}
53
+ //~^ foo_functions
52
54
fn food(&self) {}
53
55
}
54
56
55
57
// Plain functions
56
58
fn fo() {}
57
- fn foo() {} //~ ERROR: function called "foo"
59
+ fn foo() {}
60
+ //~^ foo_functions
58
61
fn food() {}
59
62
60
63
fn main() {
@@ -66,19 +69,38 @@ fn main() {
66
69
```
67
70
68
71
Without actual lint logic to emit the lint when we see a `foo` function name,
69
- this test will just pass , because no lint will be emitted. However, we can now
70
- run the test with the following command:
72
+ this test will fail , because we expect errors at lines marked with
73
+ `//~^ foo_functions`. However, we can now run the test with the following command:
71
74
72
75
```sh
73
76
$ TESTNAME=foo_functions cargo uitest
74
77
```
75
78
76
- Clippy will compile and it will conclude with an `ok` for the tests :
79
+ Clippy will compile and it will fail complaining it didn't receive any errors :
77
80
78
81
```
79
82
...Clippy warnings and test outputs...
80
- test compile_test ... ok
81
- test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.48s
83
+ error: diagnostic code `clippy::foo_functions` not found on line 8
84
+ --> tests/ui/foo_functions.rs:9:10
85
+ |
86
+ 9 | //~^ foo_functions
87
+ | ^^^^^^^^^^^^^ expected because of this pattern
88
+ |
89
+
90
+ error: diagnostic code `clippy::foo_functions` not found on line 16
91
+ --> tests/ui/foo_functions.rs:17:10
92
+ |
93
+ 17 | //~^ foo_functions
94
+ | ^^^^^^^^^^^^^ expected because of this pattern
95
+ |
96
+
97
+ error: diagnostic code `clippy::foo_functions` not found on line 23
98
+ --> tests/ui/foo_functions.rs:24:6
99
+ |
100
+ 24 | //~^ foo_functions
101
+ | ^^^^^^^^^^^^^ expected because of this pattern
102
+ |
103
+
82
104
```
83
105
84
106
This is normal. After all, we wrote a bunch of Rust code but we haven't really
0 commit comments