Skip to content

Commit bc1a1ff

Browse files
committed
Fix whitespace in pretty printed PatKind::Range
1 parent df96fb1 commit bc1a1ff

10 files changed

+12
-14
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,6 @@ impl<'a> State<'a> {
25152515
PatKind::Range(ref begin, ref end, Spanned { node: ref end_kind, .. }) => {
25162516
if let Some(e) = begin {
25172517
self.print_expr(e);
2518-
self.space();
25192518
}
25202519
match *end_kind {
25212520
RangeEnd::Included(RangeSyntax::DotDotDot) => self.word("..."),

compiler/rustc_hir_pretty/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,6 @@ impl<'a> State<'a> {
19481948
PatKind::Range(ref begin, ref end, ref end_kind) => {
19491949
if let Some(expr) = begin {
19501950
self.print_expr(expr);
1951-
self.space();
19521951
}
19531952
match *end_kind {
19541953
RangeEnd::Included => self.word("..."),

src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
22
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:8:10
33
|
44
LL | &0.. | _ => {}
5-
| ^^^ help: add parentheses to clarify the precedence: `(0 ..)`
5+
| ^^^ help: add parentheses to clarify the precedence: `(0..)`
66

77
error[E0586]: inclusive range with no end
88
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:11
@@ -16,7 +16,7 @@ error: the range pattern here has ambiguous interpretation
1616
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:10
1717
|
1818
LL | &0..= | _ => {}
19-
| ^^^^ help: add parentheses to clarify the precedence: `(0 ..=)`
19+
| ^^^^ help: add parentheses to clarify the precedence: `(0..=)`
2020

2121
error[E0586]: inclusive range with no end
2222
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11

src/test/ui/macros/stringify.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,10 @@ fn test_pat() {
712712

713713
// PatKind::Range
714714
assert_eq!(stringify_pat!(..1), "..1");
715-
assert_eq!(stringify_pat!(0..), "0 .."); // FIXME
716-
assert_eq!(stringify_pat!(0..1), "0 ..1");
717-
assert_eq!(stringify_pat!(0..=1), "0 ..=1");
718-
assert_eq!(stringify_pat!(-2..=-1), "-2 ..=-1");
715+
assert_eq!(stringify_pat!(0..), "0..");
716+
assert_eq!(stringify_pat!(0..1), "0..1");
717+
assert_eq!(stringify_pat!(0..=1), "0..=1");
718+
assert_eq!(stringify_pat!(-2..=-1), "-2..=-1");
719719

720720
// PatKind::Slice
721721
assert_eq!(stringify_pat!([]), "[]");

src/test/ui/parser/intersection-patterns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
//~| pattern on the left, should be on the right
3535
//~| binding on the right, should be on the left
3636
//~| HELP switch the order
37-
//~| SUGGESTION e @ 1 ..=5
37+
//~| SUGGESTION e @ 1..=5
3838
_ => {}
3939
}
4040
}

src/test/ui/parser/intersection-patterns.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LL | 1 ..= 5 @ e => {}
2727
| | |
2828
| | binding on the right, should be on the left
2929
| pattern on the left, should be on the right
30-
| help: switch the order: `e @ 1 ..=5`
30+
| help: switch the order: `e @ 1..=5`
3131

3232
error: aborting due to 3 previous errors
3333

src/test/ui/range/range-inclusive-pattern-precedence.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn main() {
1212
//~^ WARN `...` range patterns are deprecated
1313
//~| WARN this is accepted in the current edition
1414
//~| HELP use `..=` for an inclusive range
15-
&(10 ..=15) => {}
15+
&(10..=15) => {}
1616
//~^ ERROR the range pattern here has ambiguous interpretation
1717
//~| HELP add parentheses to clarify the precedence
1818
&(16..=20) => {}

src/test/ui/range/range-inclusive-pattern-precedence.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
22
--> $DIR/range-inclusive-pattern-precedence.rs:15:10
33
|
44
LL | &10..=15 => {}
5-
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
5+
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`
66

77
warning: `...` range patterns are deprecated
88
--> $DIR/range-inclusive-pattern-precedence.rs:11:9

src/test/ui/range/range-inclusive-pattern-precedence2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
22
--> $DIR/range-inclusive-pattern-precedence2.rs:14:13
33
|
44
LL | box 10..=15 => {}
5-
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
5+
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`
66

77
warning: `...` range patterns are deprecated
88
--> $DIR/range-inclusive-pattern-precedence2.rs:10:14

src/test/ui/unpretty-expr-fn-arg.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ extern crate std;
1414

1515
fn main() ({ } as ())
1616

17-
fn foo((-(128 as i8) as i8) ...(127 as i8): i8) ({ } as ())
17+
fn foo((-(128 as i8) as i8)...(127 as i8): i8) ({ } as ())

0 commit comments

Comments
 (0)