Skip to content

Commit 9655a85

Browse files
committed
Replace unwrap_or with explicit match
1 parent 5189851 commit 9655a85

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
@@ -1055,7 +1055,6 @@ pub(crate) struct UnusedParens {
10551055
/// ```
10561056
/// type Example = Box<dyn Fn() -> &'static dyn Send>;
10571057
/// ```
1058-
#[derive(Copy, Clone)]
10591058
enum NoBoundsException {
10601059
/// The type must be parenthesized.
10611060
None,
@@ -1336,8 +1335,12 @@ impl EarlyLintPass for UnusedParens {
13361335
ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => {
13371336
// If this type itself appears in no-bounds position, we propagate its
13381337
// potentially tighter constraint or risk a false posive (issue 143653).
1339-
let own_constraint = self.in_no_bounds_pos.get(&ty.id).copied();
1340-
let constraint = own_constraint.unwrap_or(NoBoundsException::OneBound);
1338+
let own_constraint = self.in_no_bounds_pos.get(&ty.id);
1339+
let constraint = match own_constraint {
1340+
Some(NoBoundsException::None) => NoBoundsException::None,
1341+
Some(NoBoundsException::OneBound) => NoBoundsException::OneBound,
1342+
None => NoBoundsException::OneBound,
1343+
};
13411344
self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint);
13421345
}
13431346
ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => {

0 commit comments

Comments
 (0)