diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-10-10 12:39:48 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-10-10 13:12:00 +0200 |
| commit | 5b68e1f8da35ed361633d1838988e9ce15f51620 (patch) | |
| tree | da3e84e7fff052f250ac6faa5c206b0a2469d5a2 | |
| parent | cf11ef436bb8883dce57213c27a73bc39870aa9b (diff) | |
| download | rust-5b68e1f8da35ed361633d1838988e9ce15f51620.tar.gz rust-5b68e1f8da35ed361633d1838988e9ce15f51620.zip | |
Add `Origin::Ast` arguments to all of the migrated AST-borrowck diagnostics.
| -rw-r--r-- | src/librustc_borrowck/borrowck/mod.rs | 28 | ||||
| -rw-r--r-- | src/librustc_mir/util/borrowck_errors.rs | 65 |
2 files changed, 58 insertions, 35 deletions
diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 5b5d9f5a7cf..9fe272463dd 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -618,7 +618,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { let mut err = self.cannot_act_on_moved_value(use_span, verb, msg, - &format!("{}", nl)); + &format!("{}", nl), + Origin::Ast); let need_note = match lp.ty.sty { ty::TypeVariants::TyClosure(id, _) => { let node_id = self.tcx.hir.as_local_node_id(id).unwrap(); @@ -698,7 +699,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { &self, span: Span, lp: &LoanPath<'tcx>) { - self.cannot_partially_reinit_an_uninit_struct(span, &self.loan_path_to_string(lp)) + self.cannot_partially_reinit_an_uninit_struct(span, + &self.loan_path_to_string(lp), + Origin::Ast) .emit(); } @@ -760,7 +763,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.cannot_assign(error_span, &descr, Origin::Ast) } BorrowViolation(euv::ClosureCapture(_)) => { - self.closure_cannot_assign_to_borrowed(error_span, &descr) + self.closure_cannot_assign_to_borrowed(error_span, &descr, Origin::Ast) } BorrowViolation(euv::OverloadedOperator) | BorrowViolation(euv::AddrOf) | @@ -769,7 +772,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { BorrowViolation(euv::AutoUnsafe) | BorrowViolation(euv::ForLoop) | BorrowViolation(euv::MatchDiscriminant) => { - self.cannot_borrow_path_as_mutable(error_span, &descr) + self.cannot_borrow_path_as_mutable(error_span, &descr, Origin::Ast) } BorrowViolation(euv::ClosureInvocation) => { span_bug!(err.span, @@ -851,12 +854,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { if let Some((yield_span, _)) = maybe_borrow_across_yield { debug!("err_out_of_scope: opt_yield_span = {:?}", yield_span); - self.cannot_borrow_across_generator_yield(error_span, yield_span) + self.cannot_borrow_across_generator_yield(error_span, yield_span, Origin::Ast) .emit(); return; } - let mut db = self.path_does_not_live_long_enough(error_span, &msg); + let mut db = self.path_does_not_live_long_enough(error_span, &msg, Origin::Ast); let (value_kind, value_msg) = match err.cmt.cat { mc::Categorization::Rvalue(..) => ("temporary value", "temporary value created here"), @@ -965,7 +968,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } err_borrowed_pointer_too_short(loan_scope, ptr_scope) => { let descr = self.cmt_to_path_or_string(&err.cmt); - let mut db = self.lifetime_too_short_for_reborrow(error_span, &descr); + let mut db = self.lifetime_too_short_for_reborrow(error_span, &descr, Origin::Ast); let descr = match opt_loan_path(&err.cmt) { Some(lp) => { format!("`{}`", self.loan_path_to_string(&lp)) @@ -1050,10 +1053,14 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { }; let node_id = self.tcx.hir.def_index_to_node_id(id); let help_span = self.tcx.hir.span(node_id); - self.cannot_act_on_capture_in_sharable_fn(span, prefix, (help_span, help_msg)) + self.cannot_act_on_capture_in_sharable_fn(span, + prefix, + (help_span, help_msg), + Origin::Ast) } _ => { - self.cannot_assign_into_immutable_reference(span, prefix) + self.cannot_assign_into_immutable_reference(span, prefix, + Origin::Ast) } }; self.note_immutability_blame(&mut err, blame); @@ -1207,7 +1214,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.cannot_capture_in_long_lived_closure(err.span, &cmt_path_or_string, - capture_span) + capture_span, + Origin::Ast) .span_suggestion(err.span, &format!("to force the closure to take ownership of {} \ (and any other referenced variables), \ diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 3c002b586fa..216f6e44570 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -299,100 +299,114 @@ pub trait BorrowckErrors { use_span: Span, verb: &str, optional_adverb_for_moved: &str, - moved_path: &str) + moved_path: &str, + o: Origin) -> DiagnosticBuilder { let err = struct_span_err!(self, use_span, E0382, - "{} of {}moved value: `{}`", - verb, optional_adverb_for_moved, moved_path); + "{} of {}moved value: `{}`{OGN}", + verb, optional_adverb_for_moved, moved_path, OGN=o); err } fn cannot_partially_reinit_an_uninit_struct(&self, span: Span, - uninit_path: &str) + uninit_path: &str, + o: Origin) -> DiagnosticBuilder { let err = struct_span_err!(self, span, E0383, - "partial reinitialization of uninitialized structure `{}`", - uninit_path); + "partial reinitialization of uninitialized structure `{}`{OGN}", + uninit_path, OGN=o); err } fn closure_cannot_assign_to_borrowed(&self, span: Span, - descr: &str) + descr: &str, + o: Origin) -> DiagnosticBuilder { - let err = struct_span_err!(self, span, E0595, "closure cannot assign to {}", descr); + let err = struct_span_err!(self, span, E0595, "closure cannot assign to {}{OGN}", + descr, OGN=o); err } fn cannot_borrow_path_as_mutable(&self, span: Span, - path: &str) + path: &str, + o: Origin) -> DiagnosticBuilder { - let err = struct_span_err!(self, span, E0596, "cannot borrow {} as mutable", path); + let err = struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{OGN}", + path, OGN=o); err } fn cannot_borrow_across_generator_yield(&self, span: Span, - yield_span: Span) + yield_span: Span, + o: Origin) -> DiagnosticBuilder { let mut err = struct_span_err!(self, span, E0626, - "borrow may still be in use when generator yields"); + "borrow may still be in use when generator yields{OGN}", + OGN=o); err.span_label(yield_span, "possible yield occurs here"); err } fn path_does_not_live_long_enough(&self, span: Span, - path: &str) + path: &str, + o: Origin) -> DiagnosticBuilder { - let err = struct_span_err!(self, span, E0597, "{} does not live long enough", path); + let err = struct_span_err!(self, span, E0597, "{} does not live long enough{OGN}", + path, OGN=o); err } fn lifetime_too_short_for_reborrow(&self, span: Span, - path: &str) + path: &str, + o: Origin) -> DiagnosticBuilder { let err = struct_span_err!(self, span, E0598, "lifetime of {} is too short to guarantee \ - its contents can be safely reborrowed", - path); + its contents can be safely reborrowed{OGN}", + path, OGN=o); err } fn cannot_act_on_capture_in_sharable_fn(&self, span: Span, bad_thing: &str, - help: (Span, &str)) + help: (Span, &str), + o: Origin) -> DiagnosticBuilder { let (help_span, help_msg) = help; let mut err = struct_span_err!(self, span, E0387, - "{} in a captured outer variable in an `Fn` closure", - bad_thing); + "{} in a captured outer variable in an `Fn` closure{OGN}", + bad_thing, OGN=o); err.span_help(help_span, help_msg); err } fn cannot_assign_into_immutable_reference(&self, span: Span, - bad_thing: &str) + bad_thing: &str, + o: Origin) -> DiagnosticBuilder { - let mut err = struct_span_err!(self, span, E0389, "{} in a `&` reference", bad_thing); + let mut err = struct_span_err!(self, span, E0389, "{} in a `&` reference{OGN}", + bad_thing, OGN=o); err.span_label(span, "assignment into an immutable reference"); err } @@ -400,14 +414,15 @@ pub trait BorrowckErrors { fn cannot_capture_in_long_lived_closure(&self, closure_span: Span, borrowed_path: &str, - capture_span: Span) + capture_span: Span, + o: Origin) -> DiagnosticBuilder { let mut err = struct_span_err!(self, closure_span, E0373, "closure may outlive the current function, \ but it borrows {}, \ - which is owned by the current function", - borrowed_path); + which is owned by the current function{OGN}", + borrowed_path, OGN=o); err.span_label(capture_span, format!("{} is borrowed here", borrowed_path)) .span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path)); err |
