1
Fork 0

Suggest removal of semicolon (instead of being help)

This commit is contained in:
Esteban Küber 2017-06-24 01:09:57 -07:00
parent c023856b38
commit ecde91a69d
6 changed files with 14 additions and 37 deletions

View file

@ -47,7 +47,12 @@ impl Emitter for EmitterWriter {
// don't display multiline suggestions as labels
sugg.substitution_parts[0].substitutions[0].find('\n').is_none() {
let substitution = &sugg.substitution_parts[0].substitutions[0];
let msg = format!("help: {} `{}`", sugg.msg, substitution);
let msg = if substitution.len() == 0 {
// This substitution is only removal, don't show it
format!("help: {}", sugg.msg)
} else {
format!("help: {} `{}`", sugg.msg, substitution)
};
primary_span.push_span_label(sugg.substitution_spans().next().unwrap(), msg);
} else {
// if there are multiple suggestions, print them all in full

View file

@ -4391,7 +4391,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hi: original_span.hi,
ctxt: original_span.ctxt,
};
err.span_help(span_semi, "consider removing this semicolon:");
err.span_suggestion(span_semi, "consider removing this semicolon", "".to_string());
}
// Instantiates the given path, which must refer to an item with the given

View file

@ -5,16 +5,12 @@ error[E0308]: mismatched types
| __________________^
12 | | 0u8;
13 | | "bla".to_string(); //~ HELP consider removing this semicolon
| | - help: consider removing this semicolon
14 | | }
| |_^ expected struct `std::string::String`, found ()
|
= note: expected type `std::string::String`
found type `()`
help: consider removing this semicolon:
--> $DIR/consider-removing-last-semi.rs:13:22
|
13 | "bla".to_string(); //~ HELP consider removing this semicolon
| ^
error[E0308]: mismatched types
--> $DIR/consider-removing-last-semi.rs:16:18
@ -23,16 +19,12 @@ error[E0308]: mismatched types
| __________________^
17 | | "this won't work".to_string();
18 | | "removeme".to_string(); //~ HELP consider removing this semicolon
| | - help: consider removing this semicolon
19 | | }
| |_^ expected struct `std::string::String`, found ()
|
= note: expected type `std::string::String`
found type `()`
help: consider removing this semicolon:
--> $DIR/consider-removing-last-semi.rs:18:27
|
18 | "removeme".to_string(); //~ HELP consider removing this semicolon
| ^
error: aborting due to previous error(s)

View file

@ -6,16 +6,12 @@ error[E0308]: mismatched types
12 | | 1
13 | |
14 | | ; //~ HELP consider removing this semicolon:
| | - help: consider removing this semicolon
15 | | }
| |_^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
help: consider removing this semicolon:
--> $DIR/issue-11714.rs:14:5
|
14 | ; //~ HELP consider removing this semicolon:
| ^
error: aborting due to previous error(s)

View file

@ -8,16 +8,12 @@ error[E0308]: mismatched types
16 | | // Put the trailing semicolon on its own line to test that the
17 | | // note message gets the offending semicolon exactly
18 | | ; //~ HELP consider removing this semicolon
| | - help: consider removing this semicolon
19 | | }
| |_^ expected struct `std::string::String`, found ()
|
= note: expected type `std::string::String`
found type `()`
help: consider removing this semicolon:
--> $DIR/issue-13428.rs:18:5
|
18 | ; //~ HELP consider removing this semicolon
| ^
error[E0308]: mismatched types
--> $DIR/issue-13428.rs:21:20
@ -26,16 +22,12 @@ error[E0308]: mismatched types
| ____________________^
22 | | "foobar".to_string()
23 | | ; //~ HELP consider removing this semicolon
| | - help: consider removing this semicolon
24 | | }
| |_^ expected struct `std::string::String`, found ()
|
= note: expected type `std::string::String`
found type `()`
help: consider removing this semicolon:
--> $DIR/issue-13428.rs:23:5
|
23 | ; //~ HELP consider removing this semicolon
| ^
error: aborting due to previous error(s)

View file

@ -4,16 +4,12 @@ error[E0308]: mismatched types
13 | fn plus_one(x: i32) -> i32 {
| ____________________________^
14 | | x + 1;
| | - help: consider removing this semicolon
15 | | }
| |_^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
help: consider removing this semicolon:
--> $DIR/coercion-missing-tail-expected-type.rs:14:10
|
14 | x + 1;
| ^
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:17:29
@ -21,16 +17,12 @@ error[E0308]: mismatched types
17 | fn foo() -> Result<u8, u64> {
| _____________________________^
18 | | Ok(1);
| | - help: consider removing this semicolon
19 | | }
| |_^ expected enum `std::result::Result`, found ()
|
= note: expected type `std::result::Result<u8, u64>`
found type `()`
help: consider removing this semicolon:
--> $DIR/coercion-missing-tail-expected-type.rs:18:10
|
18 | Ok(1);
| ^
error: aborting due to previous error(s)