mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 23:24:29 +00:00
match_like_matches_macro
This commit is contained in:
parent
2ae2512378
commit
add40c8660
9 changed files with 29 additions and 43 deletions
|
@ -175,7 +175,6 @@ field_reassign_with_default = "allow"
|
|||
forget_non_drop = "allow"
|
||||
format_collect = "allow"
|
||||
large_enum_variant = "allow"
|
||||
match_like_matches_macro = "allow"
|
||||
match_single_binding = "allow"
|
||||
needless_borrow = "allow"
|
||||
needless_doctest_main = "allow"
|
||||
|
|
|
@ -259,10 +259,8 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: CrateId) -> bool {
|
|||
None => continue,
|
||||
};
|
||||
|
||||
let segments = tt.split(|tt| match tt {
|
||||
tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ',' => true,
|
||||
_ => false,
|
||||
});
|
||||
let segments =
|
||||
tt.split(|tt| matches!(tt, tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ','));
|
||||
for output in segments.skip(1) {
|
||||
match output {
|
||||
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.text == "no_std" => {
|
||||
|
|
|
@ -382,11 +382,11 @@ impl Query {
|
|||
}
|
||||
|
||||
fn matches_assoc_mode(&self, is_trait_assoc_item: IsTraitAssocItem) -> bool {
|
||||
match (is_trait_assoc_item, self.assoc_mode) {
|
||||
!matches!(
|
||||
(is_trait_assoc_item, self.assoc_mode),
|
||||
(IsTraitAssocItem::Yes, AssocSearchMode::Exclude)
|
||||
| (IsTraitAssocItem::No, AssocSearchMode::AssocItemsOnly) => false,
|
||||
_ => true,
|
||||
}
|
||||
| (IsTraitAssocItem::No, AssocSearchMode::AssocItemsOnly)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1387,10 +1387,10 @@ impl Evaluator<'_> {
|
|||
| CastKind::PointerExposeAddress
|
||||
| CastKind::PointerFromExposedAddress => {
|
||||
let current_ty = self.operand_ty(operand, locals)?;
|
||||
let is_signed = match current_ty.kind(Interner) {
|
||||
TyKind::Scalar(chalk_ir::Scalar::Int(_)) => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_signed = matches!(
|
||||
current_ty.kind(Interner),
|
||||
TyKind::Scalar(chalk_ir::Scalar::Int(_))
|
||||
);
|
||||
let current = pad16(self.eval_operand(operand, locals)?.get(self)?, is_signed);
|
||||
let dest_size =
|
||||
self.size_of_sized(target_ty, locals, "destination of int to int cast")?;
|
||||
|
|
|
@ -2495,14 +2495,7 @@ impl Trait {
|
|||
db.generic_params(GenericDefId::from(self.id))
|
||||
.type_or_consts
|
||||
.iter()
|
||||
.filter(|(_, ty)| match ty {
|
||||
TypeOrConstParamData::TypeParamData(ty)
|
||||
if ty.provenance != TypeParamProvenance::TypeParamList =>
|
||||
{
|
||||
false
|
||||
}
|
||||
_ => true,
|
||||
})
|
||||
.filter(|(_, ty)| !matches!(ty, TypeOrConstParamData::TypeParamData(ty) if ty.provenance != TypeParamProvenance::TypeParamList))
|
||||
.filter(|(_, ty)| !count_required_only || !ty.has_default())
|
||||
.count()
|
||||
}
|
||||
|
@ -3872,10 +3865,7 @@ impl Type {
|
|||
}
|
||||
|
||||
pub fn is_int_or_uint(&self) -> bool {
|
||||
match self.ty.kind(Interner) {
|
||||
TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)))
|
||||
}
|
||||
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
|
|
|
@ -185,10 +185,10 @@ fn normalize(name: &str) -> Option<String> {
|
|||
}
|
||||
|
||||
fn is_valid_name(name: &str) -> bool {
|
||||
match ide_db::syntax_helpers::LexedStr::single_token(name) {
|
||||
Some((syntax::SyntaxKind::IDENT, _error)) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
ide_db::syntax_helpers::LexedStr::single_token(name),
|
||||
Some((syntax::SyntaxKind::IDENT, _error))
|
||||
)
|
||||
}
|
||||
|
||||
fn is_useless_method(method: &ast::MethodCallExpr) -> bool {
|
||||
|
|
|
@ -186,14 +186,13 @@ impl TypeLocation {
|
|||
}
|
||||
|
||||
pub(crate) fn complete_consts(&self) -> bool {
|
||||
match self {
|
||||
matches!(
|
||||
self,
|
||||
TypeLocation::GenericArg {
|
||||
corresponding_param: Some(ast::GenericParam::ConstParam(_)),
|
||||
..
|
||||
} => true,
|
||||
TypeLocation::AssocConstEq => true,
|
||||
_ => false,
|
||||
}
|
||||
} | TypeLocation::AssocConstEq
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn complete_types(&self) -> bool {
|
||||
|
|
|
@ -57,11 +57,11 @@ fn render(
|
|||
) -> Option<Builder> {
|
||||
let db = completion.db;
|
||||
let mut kind = thing.kind(db);
|
||||
let should_add_parens = match &path_ctx {
|
||||
PathCompletionCtx { has_call_parens: true, .. } => false,
|
||||
PathCompletionCtx { kind: PathKind::Use | PathKind::Type { .. }, .. } => false,
|
||||
_ => true,
|
||||
};
|
||||
let should_add_parens = !matches!(
|
||||
path_ctx,
|
||||
PathCompletionCtx { has_call_parens: true, .. }
|
||||
| PathCompletionCtx { kind: PathKind::Use | PathKind::Type { .. }, .. }
|
||||
);
|
||||
|
||||
let fields = thing.fields(completion)?;
|
||||
let (qualified_name, short_qualified_name, qualified) = match path {
|
||||
|
|
|
@ -383,10 +383,10 @@ impl Query {
|
|||
}
|
||||
|
||||
fn matches_assoc_mode(&self, is_trait_assoc_item: bool) -> bool {
|
||||
match (is_trait_assoc_item, self.assoc_mode) {
|
||||
(true, AssocSearchMode::Exclude) | (false, AssocSearchMode::AssocItemsOnly) => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(
|
||||
(is_trait_assoc_item, self.assoc_mode),
|
||||
(true, AssocSearchMode::Exclude) | (false, AssocSearchMode::AssocItemsOnly)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue