Use more slice patterns inside the compiler
This commit is contained in:
parent
60d146580c
commit
c4c518d2d4
40 changed files with 191 additions and 221 deletions
|
@ -943,8 +943,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// The current method call returns `Result<_, ()>`
|
||||
&& self.can_eq(obligation.param_env, ty, found_ty)
|
||||
// There's a single argument in the method call and it is a closure
|
||||
&& args.len() == 1
|
||||
&& let Some(arg) = args.get(0)
|
||||
&& let [arg] = args
|
||||
&& let hir::ExprKind::Closure(closure) = arg.kind
|
||||
// The closure has a block for its body with no tail expression
|
||||
&& let body = self.tcx.hir().body(closure.body)
|
||||
|
|
|
@ -73,10 +73,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
});
|
||||
|
||||
let impl_def_id_and_args = if self_match_impls.len() == 1 {
|
||||
self_match_impls[0]
|
||||
} else if fuzzy_match_impls.len() == 1 {
|
||||
fuzzy_match_impls[0]
|
||||
let impl_def_id_and_args = if let [impl_] = self_match_impls[..] {
|
||||
impl_
|
||||
} else if let [impl_] = fuzzy_match_impls[..] {
|
||||
impl_
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
|
|
@ -5300,7 +5300,8 @@ impl<'v> Visitor<'v> for FindTypeParam {
|
|||
match ty.kind {
|
||||
hir::TyKind::Ptr(_) | hir::TyKind::Ref(..) | hir::TyKind::TraitObject(..) => {}
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, path))
|
||||
if path.segments.len() == 1 && path.segments[0].ident.name == self.param =>
|
||||
if let [segment] = path.segments
|
||||
&& segment.ident.name == self.param =>
|
||||
{
|
||||
if !self.nested {
|
||||
debug!(?ty, "FindTypeParam::visit_ty");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue