@@ -88,13 +88,13 @@ As we gradually implement our lint logic, we will keep running this UI test comm
88
88
Clippy will begin outputting information that allows us to check if the output is
89
89
turning into what we want it to be.
90
90
91
+ blyxyas marked this conversation as resolved.
91
92
### Example output
92
93
93
94
As our ` foo_functions ` lint is tested, the output would look something like this:
94
95
95
96
```
96
97
failures:
97
-
98
98
---- compile_test stdout ----
99
99
normalized stderr:
100
100
error: function called "foo"
@@ -104,19 +104,16 @@ LL | pub fn foo(&self) {}
104
104
| ^^^
105
105
|
106
106
= note: `-D clippy::foo-functions` implied by `-D warnings`
107
-
108
107
error: function called "foo"
109
108
--> $DIR/foo_functions.rs:13:8
110
109
|
111
110
LL | fn foo(&self) {}
112
111
| ^^^
113
-
114
112
error: function called "foo"
115
113
--> $DIR/foo_functions.rs:19:4
116
114
|
117
115
LL | fn foo() {}
118
116
| ^^^
119
-
120
117
error: aborting due to 3 previous errors
121
118
```
122
119
@@ -191,23 +188,23 @@ and prepending the `TESTNAME` variable to `cargo uitest` works for Cargo lints t
191
188
192
189
## Rustfix Tests
193
190
194
- If the lint you are working on is making use of structured suggestions, the test
195
- file should include a ` // run-rustfix ` comment at the top.
191
+ If the lint you are working on is making use of structured suggestions,
192
+ ` rustfix ` will apply the suggestions from the lint to the test file code and
193
+ compare that to the contents of a ` .fixed ` file.
196
194
197
195
Structured suggestions tell a user how to fix or re-write certain code that has
198
196
been linted with [ ` span_lint_and_sugg ` ] .
199
197
200
- The ` // run-rustfix ` comment will additionally run [ rustfix ] for our test.
201
- Rustfix will apply the suggestions from the lint to the test file code and
202
- compare that to the contents of a ` .fixed ` file.
198
+ Should ` span_lint_and_sugg ` be used to generate a suggestion, but not all
199
+ suggestions lead to valid code, you can use the ` //@no-rustfix ` comment on top
200
+ of the test file, to not run ` rustfix ` on that file.
203
201
204
202
We'll talk about suggestions more in depth in a later chapter.
205
203
<!-- FIXME: (blyxyas) Link to "Emitting lints" when that gets merged -->
206
204
207
205
Use ` cargo bless ` to automatically generate the ` .fixed ` file after running
208
206
the tests.
209
207
210
- [ rustfix ] : https://github.com/rust-lang/rustfix
211
208
[ `span_lint_and_sugg` ] : https://doc.rust-lang.org/beta/nightly-rustc/clippy_utils/diagnostics/fn.span_lint_and_sugg.html
212
209
213
210
## Testing Manually
0 commit comments