Skip to content

Commit a1bd412

Browse files
committed
Update/bless clippy tests.
1 parent 8beba6a commit a1bd412

File tree

5 files changed

+47
-52
lines changed

5 files changed

+47
-52
lines changed

src/tools/clippy/tests/ui/author/macro_in_closure.stdout

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,35 @@ if let StmtKind::Let(local) = stmt.kind
99
&& let ExprKind::Call(func, args) = e.kind
1010
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
1111
&& args.len() == 1
12-
&& let ExprKind::Call(func1, args1) = args[0].kind
13-
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
14-
&& args1.len() == 2
12+
&& let ExprKind::Block(block1, None) = args[0].kind
13+
&& block1.stmts.len() == 1
14+
&& let StmtKind::Let(local1) = block1.stmts[0].kind
15+
&& let Some(init1) = local1.init
16+
&& let ExprKind::Array(elements) = init1.kind
17+
&& elements.len() == 1
18+
&& let ExprKind::Call(func1, args1) = elements[0].kind
19+
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
20+
&& args1.len() == 1
1521
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
16-
&& let ExprKind::Array(elements) = inner.kind
17-
&& elements.len() == 2
18-
&& let ExprKind::Lit(ref lit) = elements[0].kind
22+
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind
23+
&& name.as_str() == "args"
24+
&& let Some(trailing_expr) = block1.expr
25+
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
26+
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
27+
&& args2.len() == 2
28+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
29+
&& let ExprKind::Array(elements1) = inner1.kind
30+
&& elements1.len() == 2
31+
&& let ExprKind::Lit(ref lit) = elements1[0].kind
1932
&& let LitKind::Str(s, _) = lit.node
2033
&& s.as_str() == ""
21-
&& let ExprKind::Lit(ref lit1) = elements[1].kind
34+
&& let ExprKind::Lit(ref lit1) = elements1[1].kind
2235
&& let LitKind::Str(s1, _) = lit1.node
2336
&& s1.as_str() == "\n"
24-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args1[1].kind
25-
&& let ExprKind::Array(elements1) = inner1.kind
26-
&& elements1.len() == 1
27-
&& let ExprKind::Call(func2, args2) = elements1[0].kind
28-
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
29-
&& args2.len() == 1
30-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
37+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
3138
&& block.expr.is_none()
32-
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
33-
&& name.as_str() == "print_text"
39+
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
40+
&& name1.as_str() == "print_text"
3441
{
3542
// report your lint here
3643
}

src/tools/clippy/tests/ui/author/macro_in_loop.stdout

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,32 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
1919
&& let ExprKind::Call(func, args) = e1.kind
2020
&& paths::STD_IO_STDIO__PRINT.matches_path(cx, func) // Add the path to `clippy_utils::paths` if needed
2121
&& args.len() == 1
22-
&& let ExprKind::Call(func1, args1) = args[0].kind
23-
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
24-
&& args1.len() == 2
22+
&& let ExprKind::Block(block2, None) = args[0].kind
23+
&& block2.stmts.len() == 1
24+
&& let StmtKind::Let(local) = block2.stmts[0].kind
25+
&& let Some(init) = local.init
26+
&& let ExprKind::Array(elements) = init.kind
27+
&& elements.len() == 1
28+
&& let ExprKind::Call(func1, args1) = elements[0].kind
29+
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func1) // Add the path to `clippy_utils::paths` if needed
30+
&& args1.len() == 1
2531
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = args1[0].kind
26-
&& let ExprKind::Array(elements) = inner.kind
27-
&& elements.len() == 2
28-
&& let ExprKind::Lit(ref lit2) = elements[0].kind
32+
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
33+
&& name1.as_str() == "args"
34+
&& let Some(trailing_expr) = block2.expr
35+
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
36+
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
37+
&& args2.len() == 2
38+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
39+
&& let ExprKind::Array(elements1) = inner1.kind
40+
&& elements1.len() == 2
41+
&& let ExprKind::Lit(ref lit2) = elements1[0].kind
2942
&& let LitKind::Str(s, _) = lit2.node
3043
&& s.as_str() == ""
31-
&& let ExprKind::Lit(ref lit3) = elements[1].kind
44+
&& let ExprKind::Lit(ref lit3) = elements1[1].kind
3245
&& let LitKind::Str(s1, _) = lit3.node
3346
&& s1.as_str() == "\n"
34-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args1[1].kind
35-
&& let ExprKind::Array(elements1) = inner1.kind
36-
&& elements1.len() == 1
37-
&& let ExprKind::Call(func2, args2) = elements1[0].kind
38-
&& paths::CORE_FMT_RT_ARGUMENT_NEW_DISPLAY.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
39-
&& args2.len() == 1
40-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[0].kind
47+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
4148
&& block1.expr.is_none()
4249
&& block.expr.is_none()
4350
{

src/tools/clippy/tests/ui/manual_inspect.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ fn main() {
154154
});
155155

156156
let _ = [0]
157-
//~^ suspicious_map
158157
.into_iter()
159158
.inspect(|&x| {
160159
//~^ manual_inspect

src/tools/clippy/tests/ui/manual_inspect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ fn main() {
165165
});
166166

167167
let _ = [0]
168-
//~^ suspicious_map
169168
.into_iter()
170169
.map(|x| {
171170
//~^ manual_inspect

src/tools/clippy/tests/ui/manual_inspect.stderr

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,8 @@ LL |
157157
LL ~ println!("{}", x);
158158
|
159159

160-
error: this call to `map()` won't have an effect on the call to `count()`
161-
--> tests/ui/manual_inspect.rs:167:13
162-
|
163-
LL | let _ = [0]
164-
| _____________^
165-
LL | |
166-
LL | | .into_iter()
167-
LL | | .map(|x| {
168-
... |
169-
LL | | })
170-
LL | | .count();
171-
| |________________^
172-
|
173-
= help: make sure you did not confuse `map` with `filter`, `for_each` or `inspect`
174-
= note: `-D clippy::suspicious-map` implied by `-D warnings`
175-
= help: to override `-D warnings` add `#[allow(clippy::suspicious_map)]`
176-
177160
error: using `map` over `inspect`
178-
--> tests/ui/manual_inspect.rs:170:10
161+
--> tests/ui/manual_inspect.rs:169:10
179162
|
180163
LL | .map(|x| {
181164
| ^^^
@@ -188,7 +171,7 @@ LL ~ println!("{}", x);
188171
|
189172

190173
error: using `map` over `inspect`
191-
--> tests/ui/manual_inspect.rs:203:30
174+
--> tests/ui/manual_inspect.rs:202:30
192175
|
193176
LL | if let Some(x) = Some(1).map(|x| { println!("{x}");
194177
| ^^^
@@ -200,5 +183,5 @@ LL | // Do not collapse code into this comment
200183
LL ~ }) {
201184
|
202185

203-
error: aborting due to 14 previous errors
186+
error: aborting due to 13 previous errors
204187

0 commit comments

Comments
 (0)