Rollup merge of #81105 - LingMan:init_directly, r=nagisa
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.
This commit is contained in:
commit
b4defec768
1 changed files with 9 additions and 12 deletions
|
@ -1398,12 +1398,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option<Span> {
|
fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option<Span> {
|
||||||
generics.params.iter().enumerate().find_map(|(i, param)| {
|
generics.params.iter().enumerate().find_map(|(i, param)| {
|
||||||
if param.name.ident() == name {
|
if param.name.ident() == name {
|
||||||
let mut in_band = false;
|
let in_band = matches!(
|
||||||
if let hir::GenericParamKind::Lifetime { kind } = param.kind {
|
param.kind,
|
||||||
if let hir::LifetimeParamKind::InBand = kind {
|
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::InBand }
|
||||||
in_band = true;
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
if in_band {
|
if in_band {
|
||||||
Some(param.span)
|
Some(param.span)
|
||||||
} else if generics.params.len() == 1 {
|
} else if generics.params.len() == 1 {
|
||||||
|
@ -1433,12 +1431,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
lifetime: &hir::Lifetime,
|
lifetime: &hir::Lifetime,
|
||||||
) {
|
) {
|
||||||
let name = lifetime.name.ident();
|
let name = lifetime.name.ident();
|
||||||
let mut remove_decl = None;
|
let remove_decl = self
|
||||||
if let Some(parent_def_id) = self.tcx.parent(def_id) {
|
.tcx
|
||||||
if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
|
.parent(def_id)
|
||||||
remove_decl = self.lifetime_deletion_span(name, generics);
|
.and_then(|parent_def_id| self.tcx.hir().get_generics(parent_def_id))
|
||||||
}
|
.and_then(|generics| self.lifetime_deletion_span(name, generics));
|
||||||
}
|
|
||||||
|
|
||||||
let mut remove_use = None;
|
let mut remove_use = None;
|
||||||
let mut elide_use = None;
|
let mut elide_use = None;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue