From 8ee6ca0981e2087c24ecd8018bbb20437e8ce777 Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Fri, 18 Aug 2023 19:29:00 +0200 Subject: [PATCH] Update rustfix section to new ui-test crate --- book/src/development/writing_tests.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/book/src/development/writing_tests.md b/book/src/development/writing_tests.md index c7f67dcae9f..7cb530a3bb9 100644 --- a/book/src/development/writing_tests.md +++ b/book/src/development/writing_tests.md @@ -191,15 +191,16 @@ and prepending the `TESTNAME` variable to `cargo uitest` works for Cargo lints t ## Rustfix Tests -If the lint you are working on is making use of structured suggestions, the test -file should include a `// run-rustfix` comment at the top. +If the lint you are working on is making use of structured suggestions, +[`rustfix`] will apply the suggestions from the lint to the test file code and +compare that to the contents of a `.fixed` file. Structured suggestions tell a user how to fix or re-write certain code that has been linted with [`span_lint_and_sugg`]. -The `// run-rustfix` comment will additionally run [rustfix] for our test. -Rustfix will apply the suggestions from the lint to the test file code and -compare that to the contents of a `.fixed` file. +Should `span_lint_and_sugg` be used to generate a suggestion, but not all +suggestions lead to valid code, you can use the `//@no-rustfix` comment on top +of the test file, to not run `rustfix` on that file. We'll talk about suggestions more in depth in a later chapter. @@ -207,7 +208,7 @@ We'll talk about suggestions more in depth in a later chapter. Use `cargo bless` to automatically generate the `.fixed` file after running the tests. -[rustfix]: https://github.com/rust-lang/rustfix +[`rustfix`]: https://github.com/rust-lang/rustfix [`span_lint_and_sugg`]: https://doc.rust-lang.org/beta/nightly-rustc/clippy_utils/diagnostics/fn.span_lint_and_sugg.html ## Testing Manually