use matches!() macro in more places
This commit is contained in:
parent
3cd3bbecc5
commit
0a5640b55f
21 changed files with 49 additions and 86 deletions
|
@ -25,10 +25,7 @@ pub enum ConstEvalErrKind {
|
|||
|
||||
impl MachineStopType for ConstEvalErrKind {
|
||||
fn is_hard_err(&self) -> bool {
|
||||
match self {
|
||||
Self::Panic { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Self::Panic { .. })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,8 @@ fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
// If the function itself is not annotated with `const`, it may still be a `const fn`
|
||||
// if it resides in a const trait impl.
|
||||
is_parent_const_impl_raw(tcx, hir_id)
|
||||
} else if let hir::Node::Ctor(_) = node {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
matches!(node, hir::Node::Ctor(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,10 +138,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
|||
args: &[GenericArg<'tcx>],
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
self = print_prefix(self)?;
|
||||
let args = args.iter().cloned().filter(|arg| match arg.unpack() {
|
||||
GenericArgKind::Lifetime(_) => false,
|
||||
_ => true,
|
||||
});
|
||||
let args =
|
||||
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
|
||||
if args.clone().next().is_some() {
|
||||
self.generic_delimiters(|cx| cx.comma_sep(args))
|
||||
} else {
|
||||
|
|
|
@ -345,10 +345,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
|
||||
// Figure out how to pass which arguments.
|
||||
// The Rust ABI is special: ZST get skipped.
|
||||
let rust_abi = match caller_abi {
|
||||
Abi::Rust | Abi::RustCall => true,
|
||||
_ => false,
|
||||
};
|
||||
let rust_abi = matches!(caller_abi, Abi::Rust | Abi::RustCall);
|
||||
|
||||
// We have two iterators: Where the arguments come from,
|
||||
// and where they go to.
|
||||
|
||||
|
|
|
@ -131,10 +131,7 @@ impl Qualifs<'mir, 'tcx> {
|
|||
.body
|
||||
.basic_blocks()
|
||||
.iter_enumerated()
|
||||
.find(|(_, block)| match block.terminator().kind {
|
||||
TerminatorKind::Return => true,
|
||||
_ => false,
|
||||
})
|
||||
.find(|(_, block)| matches!(block.terminator().kind, TerminatorKind::Return))
|
||||
.map(|(bb, _)| bb);
|
||||
|
||||
let return_block = match return_block {
|
||||
|
|
|
@ -170,11 +170,12 @@ impl Qualif for NeedsNonConstDrop {
|
|||
let mut selcx = SelectionContext::with_constness(&infcx, hir::Constness::Const);
|
||||
selcx.select(&obligation)
|
||||
});
|
||||
match implsrc {
|
||||
Ok(Some(ImplSource::ConstDrop(_)))
|
||||
| Ok(Some(ImplSource::Param(_, ty::BoundConstness::ConstIfConst))) => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(
|
||||
implsrc,
|
||||
Ok(Some(
|
||||
ImplSource::ConstDrop(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst)
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue