Skip to content

Commit 0a74e17

Browse files
committed
Initialize a few variables directly
Currently they are declared as `mut`, get initialized to a default value, and then possibly overwritten. By initializing to the final value directly, they don't need to be `mut` and it's clear that they don't get mutated elsewhere later on.
1 parent efdb859 commit 0a74e17

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

compiler/rustc_resolve/src/late/lifetimes.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1370,12 +1370,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13701370
fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option<Span> {
13711371
generics.params.iter().enumerate().find_map(|(i, param)| {
13721372
if param.name.ident() == name {
1373-
let mut in_band = false;
1374-
if let hir::GenericParamKind::Lifetime { kind } = param.kind {
1375-
if let hir::LifetimeParamKind::InBand = kind {
1376-
in_band = true;
1377-
}
1378-
}
1373+
let in_band = matches!(
1374+
param.kind,
1375+
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::InBand }
1376+
);
13791377
if in_band {
13801378
Some(param.span)
13811379
} else if generics.params.len() == 1 {
@@ -1405,12 +1403,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
14051403
lifetime: &hir::Lifetime,
14061404
) {
14071405
let name = lifetime.name.ident();
1408-
let mut remove_decl = None;
1409-
if let Some(parent_def_id) = self.tcx.parent(def_id) {
1410-
if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
1411-
remove_decl = self.lifetime_deletion_span(name, generics);
1412-
}
1413-
}
1406+
let remove_decl = self
1407+
.tcx
1408+
.parent(def_id)
1409+
.and_then(|parent_def_id| self.tcx.hir().get_generics(parent_def_id))
1410+
.and_then(|generics| self.lifetime_deletion_span(name, generics));
14141411

14151412
let mut remove_use = None;
14161413
let mut elide_use = None;

0 commit comments

Comments
 (0)