mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-23 02:27:39 +03:00
819373451c
rust-lang/rust-clippy#16535 This PR introduces a new configuration option, `allow-unwrap-types`, which accepts a list of type paths (e.g., `["std::sync::LockResult"]`). When configured, calling `.unwrap()` or `.expect()` on values of these types will no longer trigger the `unwrap_used` or `expect_used` lints. This is particularly useful for reducing noisy lints on patterns where unwrapping is widely considered acceptable or expected by design, such as obtaining a `std::sync::LockResult` from `Mutex::lock()`. **Changes Made** Introduced the `allow_unwrap_types: Vec<String>` field in `clippy_config`. Updated the `unwrap_expect_used` lint to check the underlying evaluated expression `ty` against the configured allowed types. Handled robust type alias resolution so that aliases like `std::sync::LockResult` accurately map to their underlying `Adt` types during lint evaluation. Added UI tests in `tests/ui-toml/unwrap_used_allowed/` to verify both allowed and disallowed cases. ---- changelog: [`unwrap_used`], [`expect_used`]: Add `allow-unwrap-types` configuration to allow unwrapping specified types.