Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace in pretty printed PatKind::Range #92420

Merged
merged 1 commit into from
Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,6 @@ impl<'a> State<'a> {
PatKind::Range(ref begin, ref end, Spanned { node: ref end_kind, .. }) => {
if let Some(e) = begin {
self.print_expr(e);
self.space();
}
match *end_kind {
RangeEnd::Included(RangeSyntax::DotDotDot) => self.word("..."),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,6 @@ impl<'a> State<'a> {
PatKind::Range(ref begin, ref end, ref end_kind) => {
if let Some(expr) = begin {
self.print_expr(expr);
self.space();
}
match *end_kind {
RangeEnd::Included => self.word("..."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:8:10
|
LL | &0.. | _ => {}
| ^^^ help: add parentheses to clarify the precedence: `(0 ..)`
| ^^^ help: add parentheses to clarify the precedence: `(0..)`

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

error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,10 @@ fn test_pat() {

// PatKind::Range
assert_eq!(stringify_pat!(..1), "..1");
assert_eq!(stringify_pat!(0..), "0 .."); // FIXME
assert_eq!(stringify_pat!(0..1), "0 ..1");
assert_eq!(stringify_pat!(0..=1), "0 ..=1");
assert_eq!(stringify_pat!(-2..=-1), "-2 ..=-1");
assert_eq!(stringify_pat!(0..), "0..");
assert_eq!(stringify_pat!(0..1), "0..1");
assert_eq!(stringify_pat!(0..=1), "0..=1");
assert_eq!(stringify_pat!(-2..=-1), "-2..=-1");

// PatKind::Slice
assert_eq!(stringify_pat!([]), "[]");
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/intersection-patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
//~| pattern on the left, should be on the right
//~| binding on the right, should be on the left
//~| HELP switch the order
//~| SUGGESTION e @ 1 ..=5
//~| SUGGESTION e @ 1..=5
_ => {}
}
}
2 changes: 1 addition & 1 deletion src/test/ui/parser/intersection-patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LL | 1 ..= 5 @ e => {}
| | |
| | binding on the right, should be on the left
| pattern on the left, should be on the right
| help: switch the order: `e @ 1 ..=5`
| help: switch the order: `e @ 1..=5`

error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/range/range-inclusive-pattern-precedence.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn main() {
//~^ WARN `...` range patterns are deprecated
//~| WARN this is accepted in the current edition
//~| HELP use `..=` for an inclusive range
&(10 ..=15) => {}
&(10..=15) => {}
//~^ ERROR the range pattern here has ambiguous interpretation
//~| HELP add parentheses to clarify the precedence
&(16..=20) => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
--> $DIR/range-inclusive-pattern-precedence.rs:15:10
|
LL | &10..=15 => {}
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`

warning: `...` range patterns are deprecated
--> $DIR/range-inclusive-pattern-precedence.rs:11:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: the range pattern here has ambiguous interpretation
--> $DIR/range-inclusive-pattern-precedence2.rs:14:13
|
LL | box 10..=15 => {}
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10..=15)`

warning: `...` range patterns are deprecated
--> $DIR/range-inclusive-pattern-precedence2.rs:10:14
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/unpretty-expr-fn-arg.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ extern crate std;

fn main() ({ } as ())

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