Adjust new suggestions to the suggestion guidelines

This commit is contained in:
Oliver Schneider 2017-07-21 13:59:17 +02:00
parent d361efac26
commit 401ab612c2
10 changed files with 40 additions and 64 deletions

View File

@ -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);
}
}

View File

@ -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?");

View File

@ -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();

View File

@ -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 {
| ^^^^^^^^

View File

@ -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));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -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 |

View File

@ -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

View File

@ -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
|

View File

@ -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`
|

View File

@ -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 `()`