diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 7a1aea15753b3..a0c4c90722d25 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -306,11 +306,7 @@ impl Span { /// Returns `self` if `self` is not the dummy span, and `other` otherwise. pub fn substitute_dummy(self, other: Span) -> Span { - if self.is_dummy() { - other - } else { - self - } + if self.is_dummy() { other } else { self } } /// Returns `true` if `self` fully encloses `other`. @@ -341,33 +337,21 @@ impl Span { pub fn trim_start(self, other: Span) -> Option { let span = self.data(); let other = other.data(); - if span.hi > other.hi { - Some(span.with_lo(cmp::max(span.lo, other.hi))) - } else { - None - } + if span.hi > other.hi { Some(span.with_lo(cmp::max(span.lo, other.hi))) } else { None } } /// Returns the source span -- this is either the supplied span, or the span for /// the macro callsite that expanded to it. pub fn source_callsite(self) -> Span { let expn_data = self.ctxt().outer_expn_data(); - if !expn_data.is_root() { - expn_data.call_site.source_callsite() - } else { - self - } + if !expn_data.is_root() { expn_data.call_site.source_callsite() } else { self } } /// The `Span` for the tokens in the previous macro expansion from which `self` was generated, /// if any. pub fn parent(self) -> Option { let expn_data = self.ctxt().outer_expn_data(); - if !expn_data.is_root() { - Some(expn_data.call_site) - } else { - None - } + if !expn_data.is_root() { Some(expn_data.call_site) } else { None } } /// Edition of the crate from which this span came. @@ -393,18 +377,10 @@ impl Span { pub fn source_callee(self) -> Option { fn source_callee(expn_data: ExpnData) -> ExpnData { let next_expn_data = expn_data.call_site.ctxt().outer_expn_data(); - if !next_expn_data.is_root() { - source_callee(next_expn_data) - } else { - expn_data - } + if !next_expn_data.is_root() { source_callee(next_expn_data) } else { expn_data } } let expn_data = self.ctxt().outer_expn_data(); - if !expn_data.is_root() { - Some(source_callee(expn_data)) - } else { - None - } + if !expn_data.is_root() { Some(source_callee(expn_data)) } else { None } } /// Checks if a span is "internal" to a macro in which `#[unstable]` @@ -1224,11 +1200,7 @@ impl SourceFile { let line_index = lookup_line(&self.lines[..], pos); assert!(line_index < self.lines.len() as isize); - if line_index >= 0 { - Some(line_index as usize) - } else { - None - } + if line_index >= 0 { Some(line_index as usize) } else { None } } pub fn line_bounds(&self, line_index: usize) -> (BytePos, BytePos) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b282c7333d617..91ab94bc684e2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -305,11 +305,7 @@ 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, @@ -1622,11 +1618,7 @@ 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 { @@ -3775,8 +3767,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &'b self, self_ty: ty::TyVid, ) -> impl Iterator, 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);