Skip to content

Commit 5b34b4e

Browse files
committed
add parens to work around rustfmt issue rust-lang#3666 and run rustfmt
rust-lang/rustfmt#3666 (comment)
1 parent d17adbd commit 5b34b4e

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

tests/ui/eq_op.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,10 @@ fn check_ignore_macro() {
8888
}
8989

9090
struct Nested {
91-
inner: ((i32,), (i32,), (i32,))
91+
inner: ((i32,), (i32,), (i32,)),
9292
}
9393

9494
fn check_nested(n1: &Nested, n2: &Nested) -> bool {
9595
// There's no `n2.inner.0.0`
96-
n1.inner.0.0 == n1.inner.0.0
97-
&& n1.inner.1.0 == n2.inner.1.0
98-
&& n1.inner.2.0 == n2.inner.2.0
99-
}
96+
(n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0
97+
}

tests/ui/suspicious_operation_groupings.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ struct SAOnly {
3232
}
3333

3434
impl S {
35-
fn a(&self) -> i32 { 0 }
35+
fn a(&self) -> i32 {
36+
0
37+
}
3638
}
3739

3840
fn do_not_give_bad_suggestions_for_this_unusual_expr(s1: &S, s2: &SAOnly) -> bool {
@@ -50,7 +52,7 @@ fn do_not_give_bad_suggestions_for_this_macro_expr(s1: &S, s2: &SAOnly) -> bool
5052
c: 1,
5153
d: 1,
5254
}
53-
}
55+
};
5456
}
5557

5658
// This is superficially similar to `buggy_ab_cmp`, but we should not suggest
@@ -162,22 +164,18 @@ fn inside_larger_boolean_expression_with_unsorted_ops(s1: &S, s2: &S) -> bool {
162164
}
163165

164166
struct Nested {
165-
inner: ((i32,), (i32,), (i32,))
167+
inner: ((i32,), (i32,), (i32,)),
166168
}
167169

168170
fn changed_middle_ident(n1: &Nested, n2: &Nested) -> bool {
169171
// There's no `n2.inner.2.0`
170-
n1.inner.0.0 == n2.inner.0.0
171-
&& n1.inner.1.0 == n2.inner.1.0
172-
&& n1.inner.2.0 == n2.inner.1.0
172+
(n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0
173173
}
174174

175175
// `eq_op` should catch this one.
176176
fn changed_initial_ident(n1: &Nested, n2: &Nested) -> bool {
177177
// There's no `n2.inner.0.0`
178-
n1.inner.0.0 == n1.inner.0.0
179-
&& n1.inner.1.0 == n2.inner.1.0
180-
&& n1.inner.2.0 == n2.inner.2.0
178+
(n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0
181179
}
182180

183181
fn inside_fn_with_similar_expression(s1: &S, s2: &S, strict: bool) -> bool {
@@ -203,11 +201,7 @@ fn maximum_unary_minus_right_tree(s1: &S, s2: &S) -> i32 {
203201

204202
fn unary_minus_and_an_if_expression(s1: &S, s2: &S) -> i32 {
205203
// There's no `s1.b`
206-
-(if -s1.a < -s2.a && -s1.a < -s2.b {
207-
s1.c
208-
} else {
209-
s2.a
210-
})
204+
-(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a })
211205
}
212206

213207
fn main() {}

0 commit comments

Comments
 (0)