Skip to content

Commit e6db481

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

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

Lines changed: 14 additions & 6 deletions
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,
@@ -1615,7 +1619,11 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: DefId, span:
16151619
impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
16161620
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
16171621
debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t);
1618-
if t == self.opaque_identity_ty { false } else { t.super_visit_with(self) }
1622+
if t == self.opaque_identity_ty {
1623+
false
1624+
} else {
1625+
t.super_visit_with(self)
1626+
}
16191627
}
16201628

16211629
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
@@ -1975,8 +1983,8 @@ fn check_impl_items_against_trait<'tcx>(
19751983
match tcx.impl_polarity(impl_id) {
19761984
ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
19771985
ty::ImplPolarity::Negative => {
1978-
if !impl_item_refs.is_empty() {
1979-
let first_item_span = tcx.hir().impl_item(impl_item_refs[0].id).span;
1986+
if let [first_item_ref, ..] = impl_item_refs {
1987+
let first_item_span = tcx.hir().impl_item(first_item_ref.id).span;
19801988
struct_span_err!(
19811989
tcx.sess,
19821990
first_item_span,
@@ -3770,8 +3778,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37703778
&'b self,
37713779
self_ty: ty::TyVid,
37723780
) -> impl Iterator<Item = (ty::PolyTraitRef<'tcx>, traits::PredicateObligation<'tcx>)>
3773-
+ Captures<'tcx>
3774-
+ 'b {
3781+
+ Captures<'tcx>
3782+
+ 'b {
37753783
// FIXME: consider using `sub_root_var` here so we
37763784
// can see through subtyping.
37773785
let ty_var_root = self.root_var(self_ty);

0 commit comments

Comments
 (0)