1
Fork 0

use slice pattern instead of calling is_empty() and [0]

This commit is contained in:
Niko Matsakis 2020-03-19 13:51:00 -04:00
parent b9e09d8f65
commit c35801e160

View file

@ -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);