diff options
| author | bors <bors@rust-lang.org> | 2022-05-08 15:00:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-08 15:00:30 +0000 |
| commit | 4667198d4f6a0fd4c2cccd0ddec4e5afbe291401 (patch) | |
| tree | e0deb4a19ca2bee054e23f3dc52fb922b5acc62b /clippy_lints/src/lib.rs | |
| parent | 9c78883fdf5ccdeef833bc99095a18dcf6312d0b (diff) | |
| parent | 597f61bbe3a861c3d77b784cc701e6a975fbe842 (diff) | |
Auto merge of #8802 - smoelius:allow-expect-unwrap-in-tests, r=llogiq
Optionally allow `expect` and `unwrap` in tests This addresses #1015, except it makes the new behavior optional. The reason for the msrv-related changes is as follows. Rather than expand `check_methods` list of arguments, it seemed easier to make `check_methods` a method of `Methods`, so that `check_methods` could access `Methods`' fields. `check_methods` had an `msrv` parameter, which I consequently made a field of `Methods`. But, to avoid adding a lifetime parameter to `Methods`, I made the field type `Option<RustcVersion>` instead of the parameter's existing type, `Option<&RustcVersion>`. This seemed sensible since `RustcVersion` implements `Copy`. But this broke a lot of code that expected an `Option<&RustcVersion>` or `&Option<RustcVersion>`. I changed all of those occurrences to `Option<RustcVersion>`. IMHO, the code is better as a result of these changes, though. The msrv-related changes are in their own commit to (hopefully) ease review. Closes #1015 changelog: optionally allow `expect` and `unwrap` in tests r? `@llogiq`
Diffstat (limited to 'clippy_lints/src/lib.rs')
| -rw-r--r-- | clippy_lints/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 3bb821a1482..6970757b56d 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -582,8 +582,17 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: }); let avoid_breaking_exported_api = conf.avoid_breaking_exported_api; + let allow_expect_in_tests = conf.allow_expect_in_tests; + let allow_unwrap_in_tests = conf.allow_unwrap_in_tests; store.register_late_pass(move || Box::new(approx_const::ApproxConstant::new(msrv))); - store.register_late_pass(move || Box::new(methods::Methods::new(avoid_breaking_exported_api, msrv))); + store.register_late_pass(move || { + Box::new(methods::Methods::new( + avoid_breaking_exported_api, + msrv, + allow_expect_in_tests, + allow_unwrap_in_tests, + )) + }); store.register_late_pass(move || Box::new(matches::Matches::new(msrv))); store.register_early_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustiveStruct::new(msrv))); store.register_late_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustiveEnum::new(msrv))); |
