mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
cargo dev fmt
This commit is contained in:
parent
e90b977a08
commit
ba1249465c
@ -480,7 +480,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, span: Span) {
|
||||
| ItemKind::ForeignMod(..) => return false,
|
||||
// We found a main function ...
|
||||
ItemKind::Fn(_, sig, _, Some(block)) if item.ident.name == sym::main => {
|
||||
let is_async = matches!(sig.header.asyncness, Async::Yes{..});
|
||||
let is_async = matches!(sig.header.asyncness, Async::Yes { .. });
|
||||
let returns_nothing = match &sig.decl.output {
|
||||
FnRetTy::Default(..) => true,
|
||||
FnRetTy::Ty(ty) if ty.kind.is_unit() => true,
|
||||
|
@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
|
||||
let has_const_generic_params = generics
|
||||
.params
|
||||
.iter()
|
||||
.any(|param| matches!(param.kind, GenericParamKind::Const{ .. }));
|
||||
.any(|param| matches!(param.kind, GenericParamKind::Const { .. }));
|
||||
|
||||
if already_const(header) || has_const_generic_params {
|
||||
return;
|
||||
|
@ -90,9 +90,10 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||
|
||||
// Exclude non-inherent impls
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
|
||||
if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. } |
|
||||
ItemKind::Trait(..))
|
||||
{
|
||||
if matches!(
|
||||
item.kind,
|
||||
ItemKind::Impl { of_trait: Some(_), .. } | ItemKind::Trait(..)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -244,9 +244,10 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||
|
||||
// Exclude non-inherent impls
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
|
||||
if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. } |
|
||||
ItemKind::Trait(..))
|
||||
{
|
||||
if matches!(
|
||||
item.kind,
|
||||
ItemKind::Impl { of_trait: Some(_), .. } | ItemKind::Trait(..)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,10 @@ impl<'tcx> mir::visit::Visitor<'tcx> for LocalUseVisitor {
|
||||
let local = place.local;
|
||||
|
||||
if local == self.used.0
|
||||
&& !matches!(ctx, PlaceContext::MutatingUse(MutatingUseContext::Drop) | PlaceContext::NonUse(_))
|
||||
&& !matches!(
|
||||
ctx,
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Drop) | PlaceContext::NonUse(_)
|
||||
)
|
||||
{
|
||||
self.used.1 = true;
|
||||
}
|
||||
|
@ -1104,7 +1104,9 @@ fn is_empty_block(expr: &Expr<'_>) -> bool {
|
||||
expr.kind,
|
||||
ExprKind::Block(
|
||||
Block {
|
||||
stmts: &[], expr: None, ..
|
||||
stmts: &[],
|
||||
expr: None,
|
||||
..
|
||||
},
|
||||
_,
|
||||
)
|
||||
|
@ -74,7 +74,10 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
|
||||
}
|
||||
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
|
||||
if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), ..} | ItemKind::Trait(..)) {
|
||||
if matches!(
|
||||
item.kind,
|
||||
ItemKind::Impl { of_trait: Some(_), .. } | ItemKind::Trait(..)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +408,10 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
|
||||
}
|
||||
|
||||
pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
|
||||
matches!((l, r), (Defaultness::Final, Defaultness::Final) | (Defaultness::Default(_), Defaultness::Default(_)))
|
||||
matches!(
|
||||
(l, r),
|
||||
(Defaultness::Final, Defaultness::Final) | (Defaultness::Default(_), Defaultness::Default(_))
|
||||
)
|
||||
}
|
||||
|
||||
pub fn eq_vis(l: &Visibility, r: &Visibility) -> bool {
|
||||
|
@ -1500,7 +1500,7 @@ pub fn is_no_std_crate(krate: &Crate<'_>) -> bool {
|
||||
/// ```
|
||||
pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
|
||||
matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. })
|
||||
matches!(item.kind, ItemKind::Impl { of_trait: Some(_), .. })
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user