Skip to content

Commit 684f407

Browse files
committed
Reformat code
1 parent 28e8ab2 commit 684f407

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

clippy_lints/src/utils/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ pub fn contains_name(name: Symbol, expr: &Expr<'_>) -> bool {
523523
cn.result
524524
}
525525

526-
527526
struct FindMacroCalls<'a> {
528527
names: Vec<&'a str>,
529528
result: Vec<Span>,
@@ -533,10 +532,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
533532
type Map = Map<'tcx>;
534533

535534
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
536-
if self.names
537-
.iter()
538-
.any(|fun| is_expn_of(expr.span, fun).is_some())
539-
{
535+
if self.names.iter().any(|fun| is_expn_of(expr.span, fun).is_some()) {
540536
self.result.push(expr.span);
541537
}
542538
// and check sub-expressions
@@ -549,9 +545,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FindMacroCalls<'a> {
549545
}
550546

551547
/// Finds calls of the specified macros in a function body.
552-
pub fn find_macro_calls(names: Vec<&str>, body: &'tcx Body<'tcx>) -> Vec<Span>
553-
{
554-
let mut fmc = FindMacroCalls { names, result: Vec::new() };
548+
pub fn find_macro_calls(names: Vec<&str>, body: &'tcx Body<'tcx>) -> Vec<Span> {
549+
let mut fmc = FindMacroCalls {
550+
names,
551+
result: Vec::new(),
552+
};
555553
fmc.visit_expr(&body.value);
556554
fmc.result
557555
}

tests/ui/assert_in_result_fn.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ struct A;
55
impl A {
66
fn result_with_assert(x: i32) -> Result<bool, String> // should emit lint
77
{
8-
assert!(x==5);
8+
assert!(x == 5);
99
Ok(true)
1010
}
1111

1212
fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
1313
{
14-
assert!(x==5, "wrong argument");
14+
assert!(x == 5, "wrong argument");
1515
Ok(true)
1616
}
1717

@@ -43,7 +43,7 @@ impl A {
4343
{
4444
if x < 0 {
4545
assert!(x % 10 != 0);
46-
} else if x<=10 {
46+
} else if x <= 10 {
4747
assert_eq!(x, 5);
4848
} else {
4949
assert_ne!(x, 1000);
@@ -53,12 +53,12 @@ impl A {
5353

5454
fn other_with_assert(x: i32) // should not emit lint
5555
{
56-
assert!(x==5);
56+
assert!(x == 5);
5757
}
5858

5959
fn other_with_assert_with_message(x: i32) // should not emit lint
6060
{
61-
assert!(x==5, "wrong argument");
61+
assert!(x == 5, "wrong argument");
6262
}
6363

6464
fn other_with_assert_eq(x: i32) // should not emit lint
@@ -85,7 +85,7 @@ impl A {
8585
{
8686
if x < 0 {
8787
assert!(x % 10 != 0);
88-
} else if x<=10 {
88+
} else if x <= 10 {
8989
assert_eq!(x, 5);
9090
} else {
9191
assert_ne!(x, 1000);
@@ -105,7 +105,7 @@ fn assert() {}
105105

106106
fn function_result_with_assert(x: i32) -> Result<bool, String> // should emit lint
107107
{
108-
assert!(x==5);
108+
assert!(x == 5);
109109
Ok(true)
110110
}
111111

tests/ui/assert_in_result_fn.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error: used `assert!()`, `assert_eq!()` or `assert_ne!()` in a function that ret
33
|
44
LL | / fn result_with_assert(x: i32) -> Result<bool, String> // should emit lint
55
LL | | {
6-
LL | | assert!(x==5);
6+
LL | | assert!(x == 5);
77
LL | | Ok(true)
88
LL | | }
99
| |_____^
@@ -13,16 +13,16 @@ LL | | }
1313
note: return Err() if the condition is false instead of asserting
1414
--> $DIR/assert_in_result_fn.rs:8:9
1515
|
16-
LL | assert!(x==5);
17-
| ^^^^^^^^^^^^^^
16+
LL | assert!(x == 5);
17+
| ^^^^^^^^^^^^^^^^
1818
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error: used `assert!()`, `assert_eq!()` or `assert_ne!()` in a function that returns `Result`
2121
--> $DIR/assert_in_result_fn.rs:12:5
2222
|
2323
LL | / fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
2424
LL | | {
25-
LL | | assert!(x==5, "wrong argument");
25+
LL | | assert!(x == 5, "wrong argument");
2626
LL | | Ok(true)
2727
LL | | }
2828
| |_____^
@@ -31,8 +31,8 @@ LL | | }
3131
note: return Err() if the condition is false instead of asserting
3232
--> $DIR/assert_in_result_fn.rs:14:9
3333
|
34-
LL | assert!(x==5, "wrong argument");
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
LL | assert!(x == 5, "wrong argument");
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3737

3838
error: used `assert!()`, `assert_eq!()` or `assert_ne!()` in a function that returns `Result`
@@ -125,7 +125,7 @@ note: return Err() if the condition is false instead of asserting
125125
|
126126
LL | assert!(x % 10 != 0);
127127
| ^^^^^^^^^^^^^^^^^^^^^
128-
LL | } else if x<=10 {
128+
LL | } else if x <= 10 {
129129
LL | assert_eq!(x, 5);
130130
| ^^^^^^^^^^^^^^^^^
131131
LL | } else {
@@ -138,7 +138,7 @@ error: used `assert!()`, `assert_eq!()` or `assert_ne!()` in a function that ret
138138
|
139139
LL | / fn function_result_with_assert(x: i32) -> Result<bool, String> // should emit lint
140140
LL | | {
141-
LL | | assert!(x==5);
141+
LL | | assert!(x == 5);
142142
LL | | Ok(true)
143143
LL | | }
144144
| |_^
@@ -147,8 +147,8 @@ LL | | }
147147
note: return Err() if the condition is false instead of asserting
148148
--> $DIR/assert_in_result_fn.rs:108:5
149149
|
150-
LL | assert!(x==5);
151-
| ^^^^^^^^^^^^^^
150+
LL | assert!(x == 5);
151+
| ^^^^^^^^^^^^^^^^
152152
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
153153

154154
error: used `assert!()`, `assert_eq!()` or `assert_ne!()` in a function that returns `Result`

0 commit comments

Comments
 (0)