Skip to content

Commit 1dae309

Browse files
committed
Run rustfmt
1 parent ad612d6 commit 1dae309

File tree

3 files changed

+696
-467
lines changed

3 files changed

+696
-467
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
6060
.cannot_act_on_uninitialized_variable(
6161
span,
6262
desired_action.as_noun(),
63-
&self.describe_place_with_options(place, IncludingDowncast(true)).unwrap_or("_".to_owned()),
63+
&self
64+
.describe_place_with_options(place, IncludingDowncast(true))
65+
.unwrap_or("_".to_owned()),
6466
Origin::Mir,
6567
)
6668
.span_label(span, format!("use of possibly uninitialized {}", item_msg))
@@ -79,7 +81,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
7981
let mut is_loop_move = false;
8082
for moi in &mois {
8183
let move_msg = ""; //FIXME: add " (into closure)"
82-
let move_span = self.mir.source_info(self.move_data.moves[**moi].source).span;
84+
let move_span = self
85+
.mir
86+
.source_info(self.move_data.moves[**moi].source)
87+
.span;
8388
if span == move_span {
8489
err.span_label(
8590
span,
@@ -120,7 +125,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
120125
let place = &self.move_data.move_paths[mpi].place;
121126

122127
if let Some(ty) = self.retrieve_type_for_place(place) {
123-
let note_msg = match self.describe_place_with_options(place, IncludingDowncast(true)) {
128+
let note_msg = match self
129+
.describe_place_with_options(place, IncludingDowncast(true))
130+
{
124131
Some(name) => format!("`{}`", name),
125132
None => "value".to_owned(),
126133
};
@@ -649,8 +656,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
649656
let local_decl = &self.mir.local_decls[*local];
650657
if let Some(name) = local_decl.name {
651658
if local_decl.can_be_made_mutable() {
652-
err.span_label(local_decl.source_info.span,
653-
format!("consider changing this to `mut {}`", name));
659+
err.span_label(
660+
local_decl.source_info.span,
661+
format!("consider changing this to `mut {}`", name),
662+
);
654663
}
655664
}
656665
}
@@ -672,7 +681,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
672681
// place is a temporary for instance, None will be returned.
673682
// `IncludingDowncast` parameter makes the function return `Err` if `ProjectionElem` is
674683
// `Downcast` and `IncludingDowncast` is true
675-
pub(super) fn describe_place_with_options(&self, place: &Place<'tcx>, including_downcast: IncludingDowncast) -> Option<String> {
684+
pub(super) fn describe_place_with_options(
685+
&self,
686+
place: &Place<'tcx>,
687+
including_downcast: IncludingDowncast,
688+
) -> Option<String> {
676689
let mut buf = String::new();
677690
match self.append_place_to_string(place, &mut buf, false, &including_downcast) {
678691
Ok(()) => Some(buf),
@@ -708,15 +721,30 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
708721
}
709722
} else {
710723
if autoderef {
711-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
724+
self.append_place_to_string(
725+
&proj.base,
726+
buf,
727+
autoderef,
728+
&including_downcast,
729+
)?;
712730
} else {
713731
buf.push_str(&"*");
714-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
732+
self.append_place_to_string(
733+
&proj.base,
734+
buf,
735+
autoderef,
736+
&including_downcast,
737+
)?;
715738
}
716739
}
717740
}
718741
ProjectionElem::Downcast(..) => {
719-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
742+
self.append_place_to_string(
743+
&proj.base,
744+
buf,
745+
autoderef,
746+
&including_downcast,
747+
)?;
720748
if including_downcast.0 {
721749
return Err(());
722750
}
@@ -730,14 +758,24 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
730758
buf.push_str(&name);
731759
} else {
732760
let field_name = self.describe_field(&proj.base, field);
733-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
761+
self.append_place_to_string(
762+
&proj.base,
763+
buf,
764+
autoderef,
765+
&including_downcast,
766+
)?;
734767
buf.push_str(&format!(".{}", field_name));
735768
}
736769
}
737770
ProjectionElem::Index(index) => {
738771
autoderef = true;
739772

740-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
773+
self.append_place_to_string(
774+
&proj.base,
775+
buf,
776+
autoderef,
777+
&including_downcast,
778+
)?;
741779
buf.push_str("[");
742780
if let Err(_) = self.append_local_to_string(index, buf) {
743781
buf.push_str("..");
@@ -749,7 +787,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
749787
// Since it isn't possible to borrow an element on a particular index and
750788
// then use another while the borrow is held, don't output indices details
751789
// to avoid confusing the end-user
752-
self.append_place_to_string(&proj.base, buf, autoderef, &including_downcast)?;
790+
self.append_place_to_string(
791+
&proj.base,
792+
buf,
793+
autoderef,
794+
&including_downcast,
795+
)?;
753796
buf.push_str(&"[..]");
754797
}
755798
};

0 commit comments

Comments
 (0)