diff options
| author | Ben Schulz <benshu@benshu.de> | 2025-07-24 20:41:30 +0200 |
|---|---|---|
| committer | Ben Schulz <benshu@benshu.de> | 2025-07-24 20:44:10 +0200 |
| commit | 307f66436b602697c8f1c49d8f455ec60a176166 (patch) | |
| tree | fca366da236c347d0e9ce32a9023c1c4a69108a6 | |
| parent | 6fc68c16e7774be27b19ae152507b471d9a1a233 (diff) | |
| download | rust-307f66436b602697c8f1c49d8f455ec60a176166.tar.gz rust-307f66436b602697c8f1c49d8f455ec60a176166.zip | |
Replace unwrap_or with explicit match
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 5873e7bd6a7..df9f3a500d9 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1062,7 +1062,6 @@ pub(crate) struct UnusedParens { /// ``` /// type Example = Box<dyn Fn() -> &'static dyn Send>; /// ``` -#[derive(Copy, Clone)] enum NoBoundsException { /// The type must be parenthesized. None, @@ -1343,8 +1342,12 @@ impl EarlyLintPass for UnusedParens { ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => { // If this type itself appears in no-bounds position, we propagate its // potentially tighter constraint or risk a false posive (issue 143653). - let own_constraint = self.in_no_bounds_pos.get(&ty.id).copied(); - let constraint = own_constraint.unwrap_or(NoBoundsException::OneBound); + let own_constraint = self.in_no_bounds_pos.get(&ty.id); + let constraint = match own_constraint { + Some(NoBoundsException::None) => NoBoundsException::None, + Some(NoBoundsException::OneBound) => NoBoundsException::OneBound, + None => NoBoundsException::OneBound, + }; self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint); } ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => { |
