Fix even more clippy warnings
This commit is contained in:
parent
bfecb18771
commit
57c6ed0c07
53 changed files with 276 additions and 520 deletions
|
@ -262,10 +262,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
| ExprKind::ThreadLocalRef(_)
|
||||
| ExprKind::Call { .. } => {
|
||||
// these are not places, so we need to make a temporary.
|
||||
debug_assert!(match Category::of(&expr.kind) {
|
||||
Some(Category::Place) => false,
|
||||
_ => true,
|
||||
});
|
||||
debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Place)));
|
||||
let temp =
|
||||
unpack!(block = this.as_temp(block, expr.temp_lifetime, expr, mutability));
|
||||
block.and(PlaceBuilder::from(temp))
|
||||
|
|
|
@ -260,10 +260,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
| ExprKind::ValueTypeAscription { .. } => {
|
||||
// these do not have corresponding `Rvalue` variants,
|
||||
// so make an operand and then return that
|
||||
debug_assert!(match Category::of(&expr.kind) {
|
||||
Some(Category::Rvalue(RvalueFunc::AsRvalue)) => false,
|
||||
_ => true,
|
||||
});
|
||||
debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Rvalue(RvalueFunc::AsRvalue))));
|
||||
let operand = unpack!(block = this.as_operand(block, scope, expr));
|
||||
block.and(Rvalue::Use(operand))
|
||||
}
|
||||
|
|
|
@ -58,10 +58,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
ExprKind::NeverToAny { source } => {
|
||||
let source = this.hir.mirror(source);
|
||||
let is_call = match source.kind {
|
||||
ExprKind::Call { .. } | ExprKind::InlineAsm { .. } => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_call = matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. });
|
||||
|
||||
// (#66975) Source could be a const of type `!`, so has to
|
||||
// exist in the generated MIR.
|
||||
|
|
|
@ -250,15 +250,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
place,
|
||||
ty,
|
||||
);
|
||||
} else if let [success, fail] = *make_target_blocks(self) {
|
||||
assert_eq!(value.ty, ty);
|
||||
let expect = self.literal_operand(test.span, value);
|
||||
let val = Operand::Copy(place);
|
||||
self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);
|
||||
} else {
|
||||
if let [success, fail] = *make_target_blocks(self) {
|
||||
assert_eq!(value.ty, ty);
|
||||
let expect = self.literal_operand(test.span, value);
|
||||
let val = Operand::Copy(place);
|
||||
self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);
|
||||
} else {
|
||||
bug!("`TestKind::Eq` should have two target blocks");
|
||||
}
|
||||
bug!("`TestKind::Eq` should have two target blocks");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,13 +331,11 @@ impl DropTree {
|
|||
}
|
||||
if let DropKind::Value = drop_data.0.kind {
|
||||
needs_block[drop_data.1] = Block::Own;
|
||||
} else {
|
||||
if drop_idx != ROOT_NODE {
|
||||
match &mut needs_block[drop_data.1] {
|
||||
pred @ Block::None => *pred = Block::Shares(drop_idx),
|
||||
pred @ Block::Shares(_) => *pred = Block::Own,
|
||||
Block::Own => (),
|
||||
}
|
||||
} else if drop_idx != ROOT_NODE {
|
||||
match &mut needs_block[drop_data.1] {
|
||||
pred @ Block::None => *pred = Block::Shares(drop_idx),
|
||||
pred @ Block::Shares(_) => *pred = Block::Own,
|
||||
Block::Own => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -461,9 +459,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let breakable_scope = self.scopes.breakable_scopes.pop().unwrap();
|
||||
assert!(breakable_scope.region_scope == region_scope);
|
||||
let break_block = self.build_exit_tree(breakable_scope.break_drops, None);
|
||||
breakable_scope.continue_drops.map(|drops| {
|
||||
self.build_exit_tree(drops, loop_block);
|
||||
});
|
||||
if let Some(drops) = breakable_scope.continue_drops { self.build_exit_tree(drops, loop_block); }
|
||||
match (normal_exit_block, break_block) {
|
||||
(Some(block), None) | (None, Some(block)) => block,
|
||||
(None, None) => self.cfg.start_new_block().unit(),
|
||||
|
|
|
@ -316,16 +316,14 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref arg) => {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![arg.to_ref()])
|
||||
} else {
|
||||
if let hir::ExprKind::Lit(ref lit) = arg.kind {
|
||||
ExprKind::Literal {
|
||||
literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true),
|
||||
user_ty: None,
|
||||
const_id: None,
|
||||
}
|
||||
} else {
|
||||
ExprKind::Unary { op: UnOp::Neg, arg: arg.to_ref() }
|
||||
} else if let hir::ExprKind::Lit(ref lit) = arg.kind {
|
||||
ExprKind::Literal {
|
||||
literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true),
|
||||
user_ty: None,
|
||||
const_id: None,
|
||||
}
|
||||
} else {
|
||||
ExprKind::Unary { op: UnOp::Neg, arg: arg.to_ref() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -337,10 +337,7 @@ impl<'tcx> PatternFolder<'tcx> for LiteralExpander {
|
|||
|
||||
impl<'tcx> Pat<'tcx> {
|
||||
pub(super) fn is_wildcard(&self) -> bool {
|
||||
match *self.kind {
|
||||
PatKind::Binding { subpattern: None, .. } | PatKind::Wild => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self.kind, PatKind::Binding { subpattern: None, .. } | PatKind::Wild)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1358,10 +1355,7 @@ impl<'tcx> Usefulness<'tcx> {
|
|||
}
|
||||
|
||||
fn is_useful(&self) -> bool {
|
||||
match *self {
|
||||
NotUseful => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(*self, NotUseful)
|
||||
}
|
||||
|
||||
fn apply_constructor<'p>(
|
||||
|
@ -1623,10 +1617,7 @@ struct IntRange<'tcx> {
|
|||
impl<'tcx> IntRange<'tcx> {
|
||||
#[inline]
|
||||
fn is_integral(ty: Ty<'_>) -> bool {
|
||||
match ty.kind() {
|
||||
ty::Char | ty::Int(_) | ty::Uint(_) | ty::Bool => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(ty.kind(), ty::Char | ty::Int(_) | ty::Uint(_) | ty::Bool)
|
||||
}
|
||||
|
||||
fn is_singleton(&self) -> bool {
|
||||
|
|
|
@ -223,10 +223,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
|
|||
BindingMode::ByValue => mutability == Mutability::Mut,
|
||||
BindingMode::ByRef(bk) => {
|
||||
write!(f, "ref ")?;
|
||||
match bk {
|
||||
BorrowKind::Mut { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(bk, BorrowKind::Mut { .. })
|
||||
}
|
||||
};
|
||||
if is_mut {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue