Skip to content

Commit c35801e

Browse files
committed
use slice pattern instead of calling is_empty() and [0]
1 parent b9e09d8 commit c35801e

File tree

1 file changed

+14
-6
lines changed
  • src/librustc_typeck/check

1 file changed

+14
-6
lines changed

src/librustc_typeck/check/mod.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,11 @@ impl<'a, 'tcx> Expectation<'tcx> {
305305
match *self {
306306
ExpectHasType(ety) => {
307307
let ety = fcx.shallow_resolve(ety);
308-
if !ety.is_ty_var() { ExpectHasType(ety) } else { NoExpectation }
308+
if !ety.is_ty_var() {
309+
ExpectHasType(ety)
310+
} else {
311+
NoExpectation
312+
}
309313
}
310314
ExpectRvalueLikeUnsized(ety) => ExpectRvalueLikeUnsized(ety),
311315
_ => NoExpectation,
@@ -1618,7 +1622,11 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: DefId, span:
16181622
impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
16191623
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
16201624
debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t);
1621-
if t == self.opaque_identity_ty { false } else { t.super_visit_with(self) }
1625+
if t == self.opaque_identity_ty {
1626+
false
1627+
} else {
1628+
t.super_visit_with(self)
1629+
}
16221630
}
16231631

16241632
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
@@ -1978,8 +1986,8 @@ fn check_impl_items_against_trait<'tcx>(
19781986
match tcx.impl_polarity(impl_id) {
19791987
ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
19801988
ty::ImplPolarity::Negative => {
1981-
if !impl_item_refs.is_empty() {
1982-
let first_item_span = tcx.hir().impl_item(impl_item_refs[0].id).span;
1989+
if let [first_item_ref, ..] = impl_item_refs {
1990+
let first_item_span = tcx.hir().impl_item(first_item_ref.id).span;
19831991
struct_span_err!(
19841992
tcx.sess,
19851993
first_item_span,
@@ -3767,8 +3775,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37673775
&'b self,
37683776
self_ty: ty::TyVid,
37693777
) -> impl Iterator<Item = (ty::PolyTraitRef<'tcx>, traits::PredicateObligation<'tcx>)>
3770-
+ Captures<'tcx>
3771-
+ 'b {
3778+
+ Captures<'tcx>
3779+
+ 'b {
37723780
// FIXME: consider using `sub_root_var` here so we
37733781
// can see through subtyping.
37743782
let ty_var_root = self.root_var(self_ty);

0 commit comments

Comments
 (0)