Skip to content

Commit c31c60c

Browse files
committed
Reword diagnostic
1 parent 8460421 commit c31c60c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10711071
// #45983: when trying to assign the contents of an argument to a binding outside of a
10721072
// closure, provide a specific message pointing this out.
10731073
if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span),
1074-
&SubregionOrigin::Subtype(TypeTrace { ref cause, .. }),
1074+
&SubregionOrigin::Subtype(_),
10751075
&RegionKind::ReFree(ref free_region)) = (&sub_origin, &sup_origin, sup_region) {
10761076
let hir = &self.tcx.hir;
10771077
if let Some(node_id) = hir.as_local_node_id(free_region.scope) {
@@ -1084,15 +1084,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10841084
let mut err = self.tcx.sess.struct_span_err(
10851085
sp,
10861086
"borrowed data cannot be moved outside of its closure");
1087-
let label = match cause.code {
1088-
ObligationCauseCode::ExprAssignable => {
1089-
"cannot be assigned to binding outside of its closure"
1090-
}
1091-
_ => "cannot be moved outside of its closure",
1092-
};
1093-
err.span_label(sp, label);
1094-
err.span_label(*closure_span, "closure you can't escape");
1095-
err.span_label(*external_span, "binding declared outside of closure");
1087+
err.span_label(sp, "cannot be moved outside of its closure");
1088+
err.span_label(*external_span,
1089+
"borrowed data cannot be moved into here...");
1090+
err.span_label(*closure_span,
1091+
"...because it cannot outlive this closure");
10961092
err.emit();
10971093
return;
10981094
}

src/test/ui/borrowck/issue-45983.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ error: borrowed data cannot be moved outside of its closure
22
--> $DIR/issue-45983.rs:17:27
33
|
44
16 | let x = None;
5-
| - binding declared outside of closure
5+
| - borrowed data cannot be moved into here...
66
17 | give_any(|y| x = Some(y));
7-
| --- ^ cannot be assigned to binding outside of its closure
7+
| --- ^ cannot be moved outside of its closure
88
| |
9-
| closure you can't escape
9+
| ...because it cannot outlive this closure
1010

1111
error: aborting due to previous error
1212

0 commit comments

Comments
 (0)