about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2020-03-19 13:51:00 -0400
committerNiko Matsakis <niko@alum.mit.edu>2020-03-26 06:52:58 -0400
commitc35801e160ed521b62348cfe6557ef7b56130282 (patch)
tree2b83879b9fdf753955ea32a4342eaaecdb03fe33
parentb9e09d8f65b9750ecb2f8e7860a1df9633735865 (diff)
downloadrust-c35801e160ed521b62348cfe6557ef7b56130282.tar.gz
rust-c35801e160ed521b62348cfe6557ef7b56130282.zip
use slice pattern instead of calling `is_empty()` and `[0]`
-rw-r--r--src/librustc_typeck/check/mod.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 98ff5ccc82f..b282c7333d6 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -305,7 +305,11 @@ impl<'a, 'tcx> Expectation<'tcx> {
         match *self {
             ExpectHasType(ety) => {
                 let ety = fcx.shallow_resolve(ety);
-                if !ety.is_ty_var() { ExpectHasType(ety) } else { NoExpectation }
+                if !ety.is_ty_var() {
+                    ExpectHasType(ety)
+                } else {
+                    NoExpectation
+                }
             }
             ExpectRvalueLikeUnsized(ety) => ExpectRvalueLikeUnsized(ety),
             _ => NoExpectation,
@@ -1618,7 +1622,11 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: DefId, span:
     impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
         fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
             debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t);
-            if t == self.opaque_identity_ty { false } else { t.super_visit_with(self) }
+            if t == self.opaque_identity_ty {
+                false
+            } else {
+                t.super_visit_with(self)
+            }
         }
 
         fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
@@ -1978,8 +1986,8 @@ fn check_impl_items_against_trait<'tcx>(
     match tcx.impl_polarity(impl_id) {
         ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
         ty::ImplPolarity::Negative => {
-            if !impl_item_refs.is_empty() {
-                let first_item_span = tcx.hir().impl_item(impl_item_refs[0].id).span;
+            if let [first_item_ref, ..] = impl_item_refs {
+                let first_item_span = tcx.hir().impl_item(first_item_ref.id).span;
                 struct_span_err!(
                     tcx.sess,
                     first_item_span,
@@ -3767,8 +3775,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         &'b self,
         self_ty: ty::TyVid,
     ) -> impl Iterator<Item = (ty::PolyTraitRef<'tcx>, traits::PredicateObligation<'tcx>)>
-    + Captures<'tcx>
-    + 'b {
+           + Captures<'tcx>
+           + 'b {
         // FIXME: consider using `sub_root_var` here so we
         // can see through subtyping.
         let ty_var_root = self.root_var(self_ty);