Skip to content

Commit 4982684

Browse files
committed
use .span_suggestion_short for &&
1 parent 19db2d2 commit 4982684

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/librustc_parse/parser/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ impl<'a> Parser<'a> {
366366
/// Error on `and` and `or` suggesting `&&` and `||` respectively.
367367
fn error_bad_logical_op(&self, bad: &str, good: &str, english: &str) {
368368
self.struct_span_err(self.token.span, &format!("`{}` is not a logical operator", bad))
369-
.span_suggestion(
369+
.span_suggestion_short(
370370
self.token.span,
371-
&format!("instead of `{}`, use `{}` to perform logical {}", bad, good, english),
371+
&format!("use `{}` to perform logical {}", good, english),
372372
good.to_string(),
373373
Applicability::MachineApplicable,
374374
)

src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,63 @@ error: `and` is not a logical operator
22
--> $DIR/issue-54109-and_instead_of_ampersands.rs:7:15
33
|
44
LL | let _ = a and b;
5-
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
5+
| ^^^ help: use `&&` to perform logical conjunction
66
|
77
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
88

99
error: `and` is not a logical operator
1010
--> $DIR/issue-54109-and_instead_of_ampersands.rs:9:10
1111
|
1212
LL | if a and b {
13-
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
13+
| ^^^ help: use `&&` to perform logical conjunction
1414
|
1515
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
1616

1717
error: `or` is not a logical operator
1818
--> $DIR/issue-54109-and_instead_of_ampersands.rs:20:15
1919
|
2020
LL | let _ = a or b;
21-
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
21+
| ^^ help: use `||` to perform logical disjunction
2222
|
2323
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
2424

2525
error: `or` is not a logical operator
2626
--> $DIR/issue-54109-and_instead_of_ampersands.rs:22:10
2727
|
2828
LL | if a or b {
29-
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
29+
| ^^ help: use `||` to perform logical disjunction
3030
|
3131
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
3232

3333
error: `and` is not a logical operator
3434
--> $DIR/issue-54109-and_instead_of_ampersands.rs:30:11
3535
|
3636
LL | if (a and b) {
37-
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
37+
| ^^^ help: use `&&` to perform logical conjunction
3838
|
3939
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
4040

4141
error: `or` is not a logical operator
4242
--> $DIR/issue-54109-and_instead_of_ampersands.rs:38:11
4343
|
4444
LL | if (a or b) {
45-
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
45+
| ^^ help: use `||` to perform logical disjunction
4646
|
4747
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
4848

4949
error: `and` is not a logical operator
5050
--> $DIR/issue-54109-and_instead_of_ampersands.rs:46:13
5151
|
5252
LL | while a and b {
53-
| ^^^ help: instead of `and`, use `&&` to perform logical conjunction: `&&`
53+
| ^^^ help: use `&&` to perform logical conjunction
5454
|
5555
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
5656

5757
error: `or` is not a logical operator
5858
--> $DIR/issue-54109-and_instead_of_ampersands.rs:54:13
5959
|
6060
LL | while a or b {
61-
| ^^ help: instead of `or`, use `||` to perform logical disjunction: `||`
61+
| ^^ help: use `||` to perform logical disjunction
6262
|
6363
= note: unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
6464

0 commit comments

Comments
 (0)