From 401ab612c26d7568f949f2f26710283cd05ca761 Mon Sep 17 00:00:00 2001
From: Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Date: Fri, 21 Jul 2017 13:59:17 +0200
Subject: [PATCH] Adjust new suggestions to the suggestion guidelines

---
 src/librustc_typeck/check/demand.rs           |  2 +-
 src/librustc_typeck/check/mod.rs              |  6 +-
 src/libsyntax/parse/parser.rs                 |  2 +-
 .../unexpected-return-on-unit.stderr          |  4 +-
 src/test/ui/did_you_mean/issue-42764.stderr   |  2 +-
 src/test/ui/issue-22644.stderr                | 64 +++++++------------
 src/test/ui/issue-42954.stderr                | 12 ++--
 .../ui/mismatched_types/issue-19109.stderr    |  2 +-
 .../ui/resolve/token-error-correct-3.stderr   |  2 +-
 .../ui/type-check/assignment-in-if.stderr     |  8 +--
 10 files changed, 40 insertions(+), 64 deletions(-)

diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index 828106df7821b..7bb8a251354e2 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                     let suggestions = compatible_variants.iter()
                         .map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
                     err.span_suggestions(expr.span,
-                                         "perhaps you meant to use a variant of the expected type",
+                                         "try using a variant of the expected type",
                                          suggestions);
                 }
             }
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index af11cacb247b6..8b6d896cf8fb5 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -2654,7 +2654,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             // Add help to type error if this is an `if` condition with an assignment
             match (expected, &expr.node) {
                 (ExpectIfCondition, &hir::ExprAssign(ref lhs, ref rhs)) => {
-                    let msg = "did you mean to compare equality?";
+                    let msg = "try comparing for equality";
                     if let (Ok(left), Ok(right)) = (
                         self.tcx.sess.codemap().span_to_snippet(lhs.span),
                         self.tcx.sess.codemap().span_to_snippet(rhs.span))
@@ -4270,7 +4270,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 hir::ExprBlock(..) => {
                     let sp = cause_span.next_point();
                     err.span_suggestion(sp,
-                                        "did you mean to add a semicolon here?",
+                                        "try adding a semicolon",
                                         ";".to_string());
                 }
                 _ => (),
@@ -4302,7 +4302,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         } = fn_decl {
             if ty.is_suggestable() {
                 err.span_suggestion(span,
-                                    "possibly return type missing here?",
+                                    "try adding a return type",
                                     format!("-> {} ", ty));
             } else {
                 err.span_label(span, "possibly return type missing here?");
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ae3edfcbf325d..1db58b5c08570 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2936,7 +2936,7 @@ impl<'a> Parser<'a> {
                         let expr_str = self.sess.codemap().span_to_snippet(expr.span)
                                                 .unwrap_or(pprust::expr_to_string(&expr));
                         err.span_suggestion(expr.span,
-                                            "if you want to compare the casted value then write:",
+                                            "try comparing the casted value",
                                             format!("({})", expr_str));
                         err.emit();
 
diff --git a/src/test/ui/block-result/unexpected-return-on-unit.stderr b/src/test/ui/block-result/unexpected-return-on-unit.stderr
index c8743c72e3107..f052883815246 100644
--- a/src/test/ui/block-result/unexpected-return-on-unit.stderr
+++ b/src/test/ui/block-result/unexpected-return-on-unit.stderr
@@ -6,11 +6,11 @@ error[E0308]: mismatched types
    |
    = note: expected type `()`
               found type `usize`
-help: did you mean to add a semicolon here?
+help: try adding a semicolon
    |
 19 |     foo();
    |          ^
-help: possibly return type missing here?
+help: try adding a return type
    |
 18 | fn bar() -> usize {
    |          ^^^^^^^^
diff --git a/src/test/ui/did_you_mean/issue-42764.stderr b/src/test/ui/did_you_mean/issue-42764.stderr
index 7ba129039bc2f..0cc157aa5bb5c 100644
--- a/src/test/ui/did_you_mean/issue-42764.stderr
+++ b/src/test/ui/did_you_mean/issue-42764.stderr
@@ -6,7 +6,7 @@ error[E0308]: mismatched types
    |
    = note: expected type `DoubleOption<_>`
               found type `usize`
-help: perhaps you meant to use a variant of the expected type
+help: try using a variant of the expected type
    |
 21 |     this_function_expects_a_double_option(DoubleOption::FirstSome(n));
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/issue-22644.stderr b/src/test/ui/issue-22644.stderr
index 144c5ef1ed6a2..c497db00c10f7 100644
--- a/src/test/ui/issue-22644.stderr
+++ b/src/test/ui/issue-22644.stderr
@@ -2,66 +2,46 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a com
   --> $DIR/issue-22644.rs:16:31
    |
 16 |     println!("{}", a as usize < long_name);
-   |                               ^ --------- interpreted as generic arguments
-   |                               |
-   |                               not interpreted as comparison
-   |
-help: if you want to compare the casted value then write:
-   |
-16 |     println!("{}", (a as usize) < long_name);
-   |                    ^^^^^^^^^^^^
+   |                    ---------- ^ --------- interpreted as generic arguments
+   |                    |          |
+   |                    |          not interpreted as comparison
+   |                    help: try comparing the casted value: `(a as usize)`
 
 error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
   --> $DIR/issue-22644.rs:17:33
    |
 17 |     println!("{}{}", a as usize < long_name, long_name);
-   |                                 ^ -------------------- interpreted as generic arguments
-   |                                 |
-   |                                 not interpreted as comparison
-   |
-help: if you want to compare the casted value then write:
-   |
-17 |     println!("{}{}", (a as usize) < long_name, long_name);
-   |                      ^^^^^^^^^^^^
+   |                      ---------- ^ -------------------- interpreted as generic arguments
+   |                      |          |
+   |                      |          not interpreted as comparison
+   |                      help: try comparing the casted value: `(a as usize)`
 
 error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
   --> $DIR/issue-22644.rs:18:31
    |
 18 |     println!("{}", a as usize < 4);
-   |                               ^ - interpreted as generic arguments
-   |                               |
-   |                               not interpreted as comparison
-   |
-help: if you want to compare the casted value then write:
-   |
-18 |     println!("{}", (a as usize) < 4);
-   |                    ^^^^^^^^^^^^
+   |                    ---------- ^ - interpreted as generic arguments
+   |                    |          |
+   |                    |          not interpreted as comparison
+   |                    help: try comparing the casted value: `(a as usize)`
 
 error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
   --> $DIR/issue-22644.rs:20:31
    |
 20 |     println!("{}{}", a: usize < long_name, long_name);
-   |                               ^ -------------------- interpreted as generic arguments
-   |                               |
-   |                               not interpreted as comparison
-   |
-help: if you want to compare the casted value then write:
-   |
-20 |     println!("{}{}", (a: usize) < long_name, long_name);
-   |                      ^^^^^^^^^^
+   |                      -------- ^ -------------------- interpreted as generic arguments
+   |                      |        |
+   |                      |        not interpreted as comparison
+   |                      help: try comparing the casted value: `(a: usize)`
 
 error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
   --> $DIR/issue-22644.rs:21:29
    |
 21 |     println!("{}", a: usize < 4);
-   |                             ^ - interpreted as generic arguments
-   |                             |
-   |                             not interpreted as comparison
-   |
-help: if you want to compare the casted value then write:
-   |
-21 |     println!("{}", (a: usize) < 4);
-   |                    ^^^^^^^^^^
+   |                    -------- ^ - interpreted as generic arguments
+   |                    |        |
+   |                    |        not interpreted as comparison
+   |                    help: try comparing the casted value: `(a: usize)`
 
 error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
   --> $DIR/issue-22644.rs:26:20
@@ -71,7 +51,7 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a com
 27 |                    4);
    |                    - interpreted as generic arguments
    |
-help: if you want to compare the casted value then write:
+help: try comparing the casted value
    |
 23 |     println!("{}", (a
 24 |                    as
@@ -86,7 +66,7 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a com
 36 |                    5);
    |                    - interpreted as generic arguments
    |
-help: if you want to compare the casted value then write:
+help: try comparing the casted value
    |
 28 |     println!("{}", (a
 29 | 
diff --git a/src/test/ui/issue-42954.stderr b/src/test/ui/issue-42954.stderr
index 35995749d3bd0..7287c8f37eb06 100644
--- a/src/test/ui/issue-42954.stderr
+++ b/src/test/ui/issue-42954.stderr
@@ -2,17 +2,13 @@ error: `<` is interpreted as a start of generic arguments for `u32`, not a compa
   --> $DIR/issue-42954.rs:13:19
    |
 13 |         $i as u32 < 0
-   |                   ^ - interpreted as generic arguments
-   |                   |
-   |                   not interpreted as comparison
+   |         --------- ^ - interpreted as generic arguments
+   |         |         |
+   |         |         not interpreted as comparison
+   |         help: try comparing the casted value: `($i as u32)`
 ...
 19 |     is_plainly_printable!(c);
    |     ------------------------- in this macro invocation
-   |
-help: if you want to compare the casted value then write:
-   |
-13 |         ($i as u32) < 0
-   |         ^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr
index 2d8d557d9f35f..714d1b397334f 100644
--- a/src/test/ui/mismatched_types/issue-19109.stderr
+++ b/src/test/ui/mismatched_types/issue-19109.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-19109.rs:14:5
    |
 13 | fn function(t: &mut Trait) {
-   |                            - help: possibly return type missing here?: `-> *mut Trait `
+   |                            - help: try adding a return type: `-> *mut Trait `
 14 |     t as *mut Trait
    |     ^^^^^^^^^^^^^^^ expected (), found *-ptr
    |
diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr
index 2e8cc40dc5175..c8e19db3707e1 100644
--- a/src/test/ui/resolve/token-error-correct-3.stderr
+++ b/src/test/ui/resolve/token-error-correct-3.stderr
@@ -35,7 +35,7 @@ error[E0308]: mismatched types
   --> $DIR/token-error-correct-3.rs:25:13
    |
 25 |             fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here?: `;`
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try adding a semicolon: `;`
    |             |
    |             expected (), found enum `std::result::Result`
    |
diff --git a/src/test/ui/type-check/assignment-in-if.stderr b/src/test/ui/type-check/assignment-in-if.stderr
index 4b8a3744bcf8a..6052b3091c7bd 100644
--- a/src/test/ui/type-check/assignment-in-if.stderr
+++ b/src/test/ui/type-check/assignment-in-if.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched types
    |        ^^^^^
    |        |
    |        expected bool, found ()
-   |        help: did you mean to compare equality?: `x == x`
+   |        help: try comparing for equality: `x == x`
    |
    = note: expected type `bool`
               found type `()`
@@ -17,7 +17,7 @@ error[E0308]: mismatched types
    |        ^^^^^^^
    |        |
    |        expected bool, found ()
-   |        help: did you mean to compare equality?: `x == x`
+   |        help: try comparing for equality: `x == x`
    |
    = note: expected type `bool`
               found type `()`
@@ -29,7 +29,7 @@ error[E0308]: mismatched types
    |        ^^^^^^^^^^^^^^^^^^^^
    |        |
    |        expected bool, found ()
-   |        help: did you mean to compare equality?: `y == (Foo { foo: x })`
+   |        help: try comparing for equality: `y == (Foo { foo: x })`
    |
    = note: expected type `bool`
               found type `()`
@@ -41,7 +41,7 @@ error[E0308]: mismatched types
    |        ^^^^^
    |        |
    |        expected bool, found ()
-   |        help: did you mean to compare equality?: `3 == x`
+   |        help: try comparing for equality: `3 == x`
    |
    = note: expected type `bool`
               found type `()`