Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514
clippy::complexity fixes
This commit is contained in:
commit
836597a881
18 changed files with 23 additions and 30 deletions
|
@ -1345,8 +1345,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
generics
|
generics
|
||||||
.params
|
.params
|
||||||
.iter()
|
.iter()
|
||||||
.find(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
|
.any(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
|
||||||
.is_some()
|
|
||||||
}
|
}
|
||||||
// Either the `bounded_ty` is not a plain type parameter, or
|
// Either the `bounded_ty` is not a plain type parameter, or
|
||||||
// it's not found in the generic type parameters list.
|
// it's not found in the generic type parameters list.
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> {
|
||||||
let bb_data = &self.body[bb];
|
let bb_data = &self.body[bb];
|
||||||
debug_assert!(hi == bb_data.statements.len());
|
debug_assert!(hi == bb_data.statements.len());
|
||||||
for &succ_bb in bb_data.terminator().successors() {
|
for &succ_bb in bb_data.terminator().successors() {
|
||||||
if self.visited.insert(succ_bb) == false {
|
if !self.visited.insert(succ_bb) {
|
||||||
if succ_bb == location.block && first_lo > 0 {
|
if succ_bb == location.block && first_lo > 0 {
|
||||||
// `succ_bb` has been seen before. If it wasn't
|
// `succ_bb` has been seen before. If it wasn't
|
||||||
// fully processed, add its first part to `stack`
|
// fully processed, add its first part to `stack`
|
||||||
|
|
|
@ -972,8 +972,7 @@ fn suggest_ampmut<'tcx>(
|
||||||
if let Some(assignment_rhs_span) = opt_assignment_rhs_span {
|
if let Some(assignment_rhs_span) = opt_assignment_rhs_span {
|
||||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) {
|
if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) {
|
||||||
let is_mutbl = |ty: &str| -> bool {
|
let is_mutbl = |ty: &str| -> bool {
|
||||||
if ty.starts_with("mut") {
|
if let Some(rest) = ty.strip_prefix("mut") {
|
||||||
let rest = &ty[3..];
|
|
||||||
match rest.chars().next() {
|
match rest.chars().next() {
|
||||||
// e.g. `&mut x`
|
// e.g. `&mut x`
|
||||||
Some(c) if c.is_whitespace() => true,
|
Some(c) if c.is_whitespace() => true,
|
||||||
|
|
|
@ -594,7 +594,7 @@ impl<'a> TraitDef<'a> {
|
||||||
GenericParamKind::Const { ty, kw_span, .. } => {
|
GenericParamKind::Const { ty, kw_span, .. } => {
|
||||||
let const_nodefault_kind = GenericParamKind::Const {
|
let const_nodefault_kind = GenericParamKind::Const {
|
||||||
ty: ty.clone(),
|
ty: ty.clone(),
|
||||||
kw_span: kw_span.clone(),
|
kw_span: *kw_span,
|
||||||
|
|
||||||
// We can't have default values inside impl block
|
// We can't have default values inside impl block
|
||||||
default: None,
|
default: None,
|
||||||
|
|
|
@ -130,8 +130,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
.tcx()
|
.tcx()
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(span, &format!("`impl` associated type signature for `{}` doesn't match `trait` associated type signature", item_name));
|
.struct_span_err(span, &format!("`impl` associated type signature for `{}` doesn't match `trait` associated type signature", item_name));
|
||||||
err.span_label(impl_sp, &format!("found"));
|
err.span_label(impl_sp, "found");
|
||||||
err.span_label(trait_sp, &format!("expected"));
|
err.span_label(trait_sp, "expected");
|
||||||
|
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,8 +230,7 @@ fn check_panic_str<'tcx>(
|
||||||
Err(_) => (None, None),
|
Err(_) => (None, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut fmt_parser =
|
let mut fmt_parser = Parser::new(fmt, style, snippet.clone(), false, ParseMode::Format);
|
||||||
Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format);
|
|
||||||
let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count();
|
let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count();
|
||||||
|
|
||||||
if n_arguments > 0 && fmt_parser.errors.is_empty() {
|
if n_arguments > 0 && fmt_parser.errors.is_empty() {
|
||||||
|
|
|
@ -363,7 +363,7 @@ impl Collector<'tcx> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if existing.is_empty() {
|
if existing.is_empty() {
|
||||||
// Add if not found
|
// Add if not found
|
||||||
let new_name = passed_lib.new_name.as_ref().map(|s| &**s); // &Option<String> -> Option<&str>
|
let new_name: Option<&str> = passed_lib.new_name.as_deref();
|
||||||
let lib = NativeLib {
|
let lib = NativeLib {
|
||||||
name: Some(Symbol::intern(new_name.unwrap_or(&passed_lib.name))),
|
name: Some(Symbol::intern(new_name.unwrap_or(&passed_lib.name))),
|
||||||
kind: passed_lib.kind,
|
kind: passed_lib.kind,
|
||||||
|
|
|
@ -986,7 +986,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
let niche = if def.repr.hide_niche() {
|
let niche = if def.repr.hide_niche() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Niche::from_scalar(dl, Size::ZERO, scalar.clone())
|
Niche::from_scalar(dl, Size::ZERO, *scalar)
|
||||||
};
|
};
|
||||||
if let Some(niche) = niche {
|
if let Some(niche) = niche {
|
||||||
match st.largest_niche {
|
match st.largest_niche {
|
||||||
|
@ -2273,7 +2273,7 @@ where
|
||||||
) -> TyMaybeWithLayout<'tcx> {
|
) -> TyMaybeWithLayout<'tcx> {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
|
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
|
||||||
let layout = Layout::scalar(cx, tag.clone());
|
let layout = Layout::scalar(cx, tag);
|
||||||
TyAndLayout { layout: tcx.intern_layout(layout), ty: tag.value.to_ty(tcx) }
|
TyAndLayout { layout: tcx.intern_layout(layout), ty: tag.value.to_ty(tcx) }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
TerminatorKind::Call {
|
TerminatorKind::Call {
|
||||||
func: exchange_malloc,
|
func: exchange_malloc,
|
||||||
args: vec![Operand::Move(size), Operand::Move(align)],
|
args: vec![Operand::Move(size), Operand::Move(align)],
|
||||||
destination: Some((Place::from(storage), success)),
|
destination: Some((storage, success)),
|
||||||
cleanup: None,
|
cleanup: None,
|
||||||
from_hir_call: false,
|
from_hir_call: false,
|
||||||
fn_span: expr_span,
|
fn_span: expr_span,
|
||||||
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transmute `*mut u8` to the box (thus far, uninitialized):
|
// Transmute `*mut u8` to the box (thus far, uninitialized):
|
||||||
let box_ = Rvalue::ShallowInitBox(Operand::Move(Place::from(storage)), value.ty);
|
let box_ = Rvalue::ShallowInitBox(Operand::Move(storage), value.ty);
|
||||||
this.cfg.push_assign(block, source_info, Place::from(result), box_);
|
this.cfg.push_assign(block, source_info, Place::from(result), box_);
|
||||||
|
|
||||||
// initialize the box contents:
|
// initialize the box contents:
|
||||||
|
|
|
@ -1068,9 +1068,7 @@ impl<'tcx> SplitWildcard<'tcx> {
|
||||||
Missing {
|
Missing {
|
||||||
nonexhaustive_enum_missing_real_variants: self
|
nonexhaustive_enum_missing_real_variants: self
|
||||||
.iter_missing(pcx)
|
.iter_missing(pcx)
|
||||||
.filter(|c| !c.is_non_exhaustive())
|
.any(|c| !c.is_non_exhaustive()),
|
||||||
.next()
|
|
||||||
.is_some(),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Missing { nonexhaustive_enum_missing_real_variants: false }
|
Missing { nonexhaustive_enum_missing_real_variants: false }
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that the value being matched on is the same. The
|
// check that the value being matched on is the same. The
|
||||||
if this_bb_discr_info.targets_with_values.iter().find(|x| x.0 == value).is_none() {
|
if !this_bb_discr_info.targets_with_values.iter().any(|x| x.0 == value) {
|
||||||
trace!("NO: values being matched on are not the same");
|
trace!("NO: values being matched on are not the same");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,7 @@ impl<'a, 'tcx> Patcher<'a, 'tcx> {
|
||||||
Operand::Copy(place) | Operand::Move(place) => {
|
Operand::Copy(place) | Operand::Move(place) => {
|
||||||
// create new local
|
// create new local
|
||||||
let ty = operand.ty(self.local_decls, self.tcx);
|
let ty = operand.ty(self.local_decls, self.tcx);
|
||||||
let local_decl =
|
let local_decl = LocalDecl::with_source_info(ty, statement.source_info);
|
||||||
LocalDecl::with_source_info(ty, statement.source_info.clone());
|
|
||||||
let local = self.local_decls.push(local_decl);
|
let local = self.local_decls.push(local_decl);
|
||||||
// make it live
|
// make it live
|
||||||
let mut make_live_statement = statement.clone();
|
let mut make_live_statement = statement.clone();
|
||||||
|
|
|
@ -1767,8 +1767,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) {
|
fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) {
|
||||||
if target != Target::MacroDef {
|
if target != Target::MacroDef {
|
||||||
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
lint.build(&format!("`#[macro_export]` only has an effect on macro definitions"))
|
lint.build("`#[macro_export]` only has an effect on macro definitions").emit();
|
||||||
.emit();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,14 +278,14 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_expr(&mut self, expr: &thir::Expr<'tcx>) {
|
fn visit_expr(&mut self, expr: &thir::Expr<'tcx>) {
|
||||||
self.is_poly |= expr.ty.definitely_has_param_types_or_consts(self.tcx);
|
self.is_poly |= expr.ty.definitely_has_param_types_or_consts(self.tcx);
|
||||||
if self.is_poly == false {
|
if !self.is_poly {
|
||||||
visit::walk_expr(self, expr)
|
visit::walk_expr(self, expr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_pat(&mut self, pat: &thir::Pat<'tcx>) {
|
fn visit_pat(&mut self, pat: &thir::Pat<'tcx>) {
|
||||||
self.is_poly |= pat.ty.definitely_has_param_types_or_consts(self.tcx);
|
self.is_poly |= pat.ty.definitely_has_param_types_or_consts(self.tcx);
|
||||||
if self.is_poly == false {
|
if !self.is_poly {
|
||||||
visit::walk_pat(self, pat);
|
visit::walk_pat(self, pat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||||
let mut is_poly_vis = IsThirPolymorphic { is_poly: false, thir: body, tcx };
|
let mut is_poly_vis = IsThirPolymorphic { is_poly: false, thir: body, tcx };
|
||||||
visit::walk_expr(&mut is_poly_vis, &body[body_id]);
|
visit::walk_expr(&mut is_poly_vis, &body[body_id]);
|
||||||
debug!("AbstractConstBuilder: is_poly={}", is_poly_vis.is_poly);
|
debug!("AbstractConstBuilder: is_poly={}", is_poly_vis.is_poly);
|
||||||
if is_poly_vis.is_poly == false {
|
if !is_poly_vis.is_poly {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -892,7 +892,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
||||||
match r {
|
match r {
|
||||||
ty::ReLateBound(index, br) if *index == self.binder_index => match br.kind {
|
ty::ReLateBound(index, br) if *index == self.binder_index => match br.kind {
|
||||||
ty::BoundRegionKind::BrNamed(def_id, _name) => {
|
ty::BoundRegionKind::BrNamed(def_id, _name) => {
|
||||||
if self.named_parameters.iter().find(|d| **d == def_id).is_none() {
|
if !self.named_parameters.iter().any(|d| *d == def_id) {
|
||||||
self.named_parameters.push(def_id);
|
self.named_parameters.push(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
ObligationCause::dummy_with_span(callee_expr.span),
|
ObligationCause::dummy_with_span(callee_expr.span),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
predicate.clone(),
|
*predicate,
|
||||||
);
|
);
|
||||||
let result = self.infcx.evaluate_obligation(&obligation);
|
let result = self.infcx.evaluate_obligation(&obligation);
|
||||||
self.tcx
|
self.tcx
|
||||||
|
|
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::Match(ref discr, arms, _) => {
|
hir::ExprKind::Match(ref discr, arms, _) => {
|
||||||
self.link_match(discr, &arms[..]);
|
self.link_match(discr, arms);
|
||||||
|
|
||||||
intravisit::walk_expr(self, expr);
|
intravisit::walk_expr(self, expr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
debug!("Done with crate");
|
debug!("Done with crate");
|
||||||
|
|
||||||
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
||||||
self.get_impls(primitive.clone());
|
self.get_impls(*primitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut index = (*self.index).clone().into_inner();
|
let mut index = (*self.index).clone().into_inner();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue