use matches!() macro in more places
This commit is contained in:
parent
c34c015fe2
commit
d12a358673
34 changed files with 138 additions and 270 deletions
|
@ -38,10 +38,9 @@ pub fn expand_deriving_clone(
|
|||
| ItemKind::Enum(_, Generics { ref params, .. }) => {
|
||||
let container_id = cx.current_expansion.id.expn_data().parent;
|
||||
if cx.resolver.has_derive_copy(container_id)
|
||||
&& !params.iter().any(|param| match param.kind {
|
||||
ast::GenericParamKind::Type { .. } => true,
|
||||
_ => false,
|
||||
})
|
||||
&& !params
|
||||
.iter()
|
||||
.any(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
|
||||
{
|
||||
bounds = vec![];
|
||||
is_shallow = true;
|
||||
|
|
|
@ -404,12 +404,10 @@ impl<'a> TraitDef<'a> {
|
|||
let has_no_type_params = match item.kind {
|
||||
ast::ItemKind::Struct(_, ref generics)
|
||||
| ast::ItemKind::Enum(_, ref generics)
|
||||
| ast::ItemKind::Union(_, ref generics) => {
|
||||
!generics.params.iter().any(|param| match param.kind {
|
||||
ast::GenericParamKind::Type { .. } => true,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
| ast::ItemKind::Union(_, ref generics) => !generics
|
||||
.params
|
||||
.iter()
|
||||
.any(|param| matches!(param.kind, ast::GenericParamKind::Type { .. })),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let container_id = cx.current_expansion.id.expn_data().parent;
|
||||
|
@ -868,7 +866,7 @@ impl<'a> MethodDef<'a> {
|
|||
Self_ if nonstatic => {
|
||||
self_args.push(arg_expr);
|
||||
}
|
||||
Ptr(ref ty, _) if (if let Self_ = **ty { true } else { false }) && nonstatic => {
|
||||
Ptr(ref ty, _) if matches!(**ty, Self_) && nonstatic => {
|
||||
self_args.push(cx.expr_deref(trait_.span, arg_expr))
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -1044,10 +1044,7 @@ pub fn expand_preparsed_format_args(
|
|||
|
||||
let numbered_position_args = pieces.iter().any(|arg: &parse::Piece<'_>| match *arg {
|
||||
parse::String(_) => false,
|
||||
parse::NextArgument(arg) => match arg.position {
|
||||
parse::Position::ArgumentIs(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
parse::NextArgument(arg) => matches!(arg.position, parse::Position::ArgumentIs(_)),
|
||||
});
|
||||
|
||||
cx.build_index_map();
|
||||
|
|
|
@ -580,10 +580,7 @@ pub mod printf {
|
|||
}
|
||||
|
||||
fn is_flag(c: &char) -> bool {
|
||||
match c {
|
||||
'0' | '-' | '+' | ' ' | '#' | '\'' => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(c, '0' | '-' | '+' | ' ' | '#' | '\'')
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -87,9 +87,11 @@ fn parse_inline_asm<'a>(
|
|||
// parsed as `llvm_asm!(z)` with `z = "x": y` which is type ascription.
|
||||
let first_colon = tts
|
||||
.trees()
|
||||
.position(|tt| match tt {
|
||||
tokenstream::TokenTree::Token(Token { kind: token::Colon | token::ModSep, .. }) => true,
|
||||
_ => false,
|
||||
.position(|tt| {
|
||||
matches!(
|
||||
tt,
|
||||
tokenstream::TokenTree::Token(Token { kind: token::Colon | token::ModSep, .. })
|
||||
)
|
||||
})
|
||||
.unwrap_or(tts.len());
|
||||
let mut p = cx.new_parser_from_tts(tts.trees().skip(first_colon).collect());
|
||||
|
|
|
@ -256,10 +256,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
|||
// we're just not interested in this item.
|
||||
//
|
||||
// If we find one, try to locate a `#[proc_macro_derive]` attribute on it.
|
||||
let is_fn = match item.kind {
|
||||
ast::ItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_fn = matches!(item.kind, ast::ItemKind::Fn(..));
|
||||
|
||||
let mut found_attr: Option<&'a ast::Attribute> = None;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue