summary refs log tree commit diff
path: root/src/test/ui/codemap_tests
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2018-07-31 17:22:12 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-07-31 17:27:29 +0200
commita5a3f765eb36aee69bfdaba1f82760973b63c780 (patch)
treedc6d1485eff0d0b0895ee7aeeab8e386d2d38686 /src/test/ui/codemap_tests
parent896113201034946c7f49c1049288665fa2a56e32 (diff)
downloadrust-a5a3f765eb36aee69bfdaba1f82760973b63c780.tar.gz
rust-a5a3f765eb36aee69bfdaba1f82760973b63c780.zip
NLL: On "cannot move out of type" error, print original source before rewrite.
 * Arguably this change is sometimes injecting noise into the output
   (namely in the cases where the suggested rewrite is inline with the
   suggestion and we end up highlighting the original source code).
   I would not be opposed to something more aggressive/dynamic, like
   revising the suggestion code to automatically print the original
   source when necessary (e.g. when the error does not have a span
   that includes the span of the suggestion).

 * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion`
   says:
    /// The message
    ///
    /// * should not end in any punctuation (a `:` is added automatically)
    /// * should not be a question
    /// * should not contain any parts like "the following", "as shown"

   but the `:` is *not* added when the emitted line appears
   out-of-line relative to the suggestion. I find that to be an
   unfortunate UI experience.

----

As a drive-by fix, also changed code to combine multiple suggestions
for a pattern into a single multipart suggestion (which vastly
improves user experience IMO).

----

Includes the updates to expected NLL diagnostics.
Diffstat (limited to 'src/test/ui/codemap_tests')
-rw-r--r--src/test/ui/codemap_tests/overlapping_spans.nll.stderr5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/test/ui/codemap_tests/overlapping_spans.nll.stderr b/src/test/ui/codemap_tests/overlapping_spans.nll.stderr
index 34616a8de45..a1fbcf1430d 100644
--- a/src/test/ui/codemap_tests/overlapping_spans.nll.stderr
+++ b/src/test/ui/codemap_tests/overlapping_spans.nll.stderr
@@ -4,7 +4,10 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
 LL |     match (S {f:"foo".to_string()}) {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
 LL |         S {f:_s} => {} //~ ERROR cannot move out
-   |              -- help: to prevent move, use ref or ref mut: `ref _s`
+   |              --
+   |              |
+   |              data moved here
+   |              help: to prevent move, use ref or ref mut: `ref _s`
 
 error: aborting due to previous error