Skip to content

Commit 307f664

Browse files
committed
Replace unwrap_or with explicit match
1 parent 6fc68c1 commit 307f664

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/rustc_lint/src/unused.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,6 @@ pub(crate) struct UnusedParens {
10621062
/// ```
10631063
/// type Example = Box<dyn Fn() -> &'static dyn Send>;
10641064
/// ```
1065-
#[derive(Copy, Clone)]
10661065
enum NoBoundsException {
10671066
/// The type must be parenthesized.
10681067
None,
@@ -1343,8 +1342,12 @@ impl EarlyLintPass for UnusedParens {
13431342
ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => {
13441343
// If this type itself appears in no-bounds position, we propagate its
13451344
// potentially tighter constraint or risk a false posive (issue 143653).
1346-
let own_constraint = self.in_no_bounds_pos.get(&ty.id).copied();
1347-
let constraint = own_constraint.unwrap_or(NoBoundsException::OneBound);
1345+
let own_constraint = self.in_no_bounds_pos.get(&ty.id);
1346+
let constraint = match own_constraint {
1347+
Some(NoBoundsException::None) => NoBoundsException::None,
1348+
Some(NoBoundsException::OneBound) => NoBoundsException::OneBound,
1349+
None => NoBoundsException::OneBound,
1350+
};
13481351
self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint);
13491352
}
13501353
ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => {

0 commit comments

Comments
 (0)