diff options
| -rw-r--r-- | src/librustc_mir/borrow_check/borrow_set.rs | 8 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/error_reporting.rs | 16 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/move_errors.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/mutability_errors.rs | 4 |
4 files changed, 16 insertions, 18 deletions
diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 18cc1430c2a..a316fc5ca10 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -92,12 +92,12 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> { mir::BorrowKind::Mut { .. } => "mut ", }; let region = self.region.to_string(); - let region = if region.len() > 0 { - format!("{} ", region) + let separator = if !region.is_empty() { + " " } else { - region + "" }; - write!(w, "&{}{}{:?}", region, kind, self.borrowed_place) + write!(w, "&{}{}{}{:?}", region, separator, kind, self.borrowed_place) } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 8d5629270fe..06918d9ebab 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -579,7 +579,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn report_local_value_does_not_live_long_enough( &mut self, context: Context, - name: &String, + name: &str, scope_tree: &Lrc<ScopeTree>, borrow: &BorrowData<'tcx>, drop_span: Span, @@ -1192,10 +1192,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Place::Static(ref static_) => self.describe_field_from_ty(&static_.ty, field), Place::Projection(ref proj) => match proj.elem { ProjectionElem::Deref => self.describe_field(&proj.base, field), - ProjectionElem::Downcast(def, variant_index) => format!( - "{}", - def.variants[variant_index].fields[field.index()].ident - ), + ProjectionElem::Downcast(def, variant_index) => + def.variants[variant_index].fields[field.index()].ident.to_string(), ProjectionElem::Field(_, field_type) => { self.describe_field_from_ty(&field_type, field) } @@ -1783,8 +1781,8 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }), _, _, - ) => with_highlight_region_for_bound_region(*br, counter, || format!("{}", ty)), - _ => format!("{}", ty), + ) => with_highlight_region_for_bound_region(*br, counter, || ty.to_string()), + _ => ty.to_string(), } } @@ -1795,9 +1793,9 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { ty::TyKind::Ref(region, _, _) => match region { ty::RegionKind::ReLateBound(_, br) | ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }) => { - with_highlight_region_for_bound_region(*br, counter, || format!("{}", region)) + with_highlight_region_for_bound_region(*br, counter, || region.to_string()) } - _ => format!("{}", region), + _ => region.to_string(), }, _ => bug!("ty for annotation of borrow region is not a reference"), } diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index ea62694f8be..a556199b875 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -331,7 +331,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { _ => { let source = self.borrowed_content_source(place); self.infcx.tcx.cannot_move_out_of( - span, &format!("{}", source), origin + span, &source.to_string(), origin ) }, } @@ -469,9 +469,9 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { let binding_span = bind_to.source_info.span; if j == 0 { - err.span_label(binding_span, format!("data moved here")); + err.span_label(binding_span, "data moved here"); } else { - err.span_label(binding_span, format!("...and here")); + err.span_label(binding_span, "...and here"); } if binds_to.len() == 1 { diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index f0b4a5ac743..30f4fc9d5ea 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -504,7 +504,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { ); let extra = if found { - String::from("") + String::new() } else { format!(", but it is not implemented for `{}`", substs.type_at(0)) @@ -583,7 +583,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>( let ty = &src[ws_pos..]; return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty)); } else if src.starts_with('&') { - let borrowed_expr = src[1..].to_string(); + let borrowed_expr = &src[1..]; return (assignment_rhs_span, format!("&mut {}", borrowed_expr)); } } |
