Skip to content

Commit 4f55e11

Browse files
committed
Make clippy happy.
1 parent 400931e commit 4f55e11

File tree

3 files changed

+60
-19
lines changed

3 files changed

+60
-19
lines changed

src/tools/clippy/clippy_utils/src/sym.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ generate! {
166166
from_ne_bytes,
167167
from_ptr,
168168
from_raw,
169-
from_str,
170169
from_str_radix,
171170
fs,
172171
fuse,

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,38 @@ if let StmtKind::Let(local) = stmt.kind
3131
&& name1.as_str() == "args"
3232
&& let Some(trailing_expr) = block1.expr
3333
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
34-
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
34+
&& paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
3535
&& args2.len() == 2
36-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
36+
&& let ExprKind::Block(block2, None) = args2[0].kind
37+
&& block2.stmts.is_empty()
38+
&& let Some(trailing_expr1) = block2.expr
39+
&& let ExprKind::Call(func3, args3) = trailing_expr1.kind
40+
&& func3.res(cx).is_diag_item(cx, sym::FmtTemplateNew)
41+
&& args3.len() == 1
42+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args3[0].kind
3743
&& let ExprKind::Array(elements2) = inner1.kind
38-
&& elements2.len() == 2
39-
&& let ExprKind::Lit(ref lit) = elements2[0].kind
40-
&& let LitKind::Str(s, _) = lit.node
41-
&& s.as_str() == ""
42-
&& let ExprKind::Lit(ref lit1) = elements2[1].kind
43-
&& let LitKind::Str(s1, _) = lit1.node
44-
&& s1.as_str() == "\n"
44+
&& elements2.len() == 4
45+
&& let ExprKind::Call(func4, args4) = elements2[0].kind
46+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func4) // Add the path to `clippy_utils::paths` if needed
47+
&& args4.len() == 1
48+
&& let ExprKind::Lit(ref lit) = args4[0].kind
49+
&& let LitKind::Int(16140901201934811136, LitIntType::Unsigned(UintTy::Usize)) = lit.node
50+
&& let ExprKind::Call(func5, args5) = elements2[1].kind
51+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func5) // Add the path to `clippy_utils::paths` if needed
52+
&& args5.len() == 1
53+
&& let ExprKind::Lit(ref lit1) = args5[0].kind
54+
&& let LitKind::Int(1, LitIntType::Unsigned(UintTy::Usize)) = lit1.node
55+
&& let ExprKind::Call(func6, args6) = elements2[2].kind
56+
&& paths::CORE_FMT_RT_PIECE_STR.matches_path(cx, func6) // Add the path to `clippy_utils::paths` if needed
57+
&& args6.len() == 1
58+
&& let ExprKind::Lit(ref lit2) = args6[0].kind
59+
&& let LitKind::Str(s, _) = lit2.node
60+
&& s.as_str() == "\n"
61+
&& let ExprKind::Call(func7, args7) = elements2[3].kind
62+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func7) // Add the path to `clippy_utils::paths` if needed
63+
&& args7.len() == 1
64+
&& let ExprKind::Lit(ref lit3) = args7[0].kind
65+
&& let LitKind::Int(0, LitIntType::Unsigned(UintTy::Usize)) = lit3.node
4566
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
4667
&& block.expr.is_none()
4768
&& let PatKind::Binding(BindingMode::NONE, _, name2, None) = local.pat.kind

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,38 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
4242
&& name2.as_str() == "args"
4343
&& let Some(trailing_expr) = block2.expr
4444
&& let ExprKind::Call(func2, args2) = trailing_expr.kind
45-
&& paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
45+
&& paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed
4646
&& args2.len() == 2
47-
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind
47+
&& let ExprKind::Block(block3, None) = args2[0].kind
48+
&& block3.stmts.is_empty()
49+
&& let Some(trailing_expr1) = block3.expr
50+
&& let ExprKind::Call(func3, args3) = trailing_expr1.kind
51+
&& func3.res(cx).is_diag_item(cx, sym::FmtTemplateNew)
52+
&& args3.len() == 1
53+
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args3[0].kind
4854
&& let ExprKind::Array(elements2) = inner1.kind
49-
&& elements2.len() == 2
50-
&& let ExprKind::Lit(ref lit2) = elements2[0].kind
51-
&& let LitKind::Str(s, _) = lit2.node
52-
&& s.as_str() == ""
53-
&& let ExprKind::Lit(ref lit3) = elements2[1].kind
54-
&& let LitKind::Str(s1, _) = lit3.node
55-
&& s1.as_str() == "\n"
55+
&& elements2.len() == 4
56+
&& let ExprKind::Call(func4, args4) = elements2[0].kind
57+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func4) // Add the path to `clippy_utils::paths` if needed
58+
&& args4.len() == 1
59+
&& let ExprKind::Lit(ref lit2) = args4[0].kind
60+
&& let LitKind::Int(16140901201934811136, LitIntType::Unsigned(UintTy::Usize)) = lit2.node
61+
&& let ExprKind::Call(func5, args5) = elements2[1].kind
62+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func5) // Add the path to `clippy_utils::paths` if needed
63+
&& args5.len() == 1
64+
&& let ExprKind::Lit(ref lit3) = args5[0].kind
65+
&& let LitKind::Int(1, LitIntType::Unsigned(UintTy::Usize)) = lit3.node
66+
&& let ExprKind::Call(func6, args6) = elements2[2].kind
67+
&& paths::CORE_FMT_RT_PIECE_STR.matches_path(cx, func6) // Add the path to `clippy_utils::paths` if needed
68+
&& args6.len() == 1
69+
&& let ExprKind::Lit(ref lit4) = args6[0].kind
70+
&& let LitKind::Str(s, _) = lit4.node
71+
&& s.as_str() == "\n"
72+
&& let ExprKind::Call(func7, args7) = elements2[3].kind
73+
&& paths::CORE_FMT_RT_PIECE_NUM.matches_path(cx, func7) // Add the path to `clippy_utils::paths` if needed
74+
&& args7.len() == 1
75+
&& let ExprKind::Lit(ref lit5) = args7[0].kind
76+
&& let LitKind::Int(0, LitIntType::Unsigned(UintTy::Usize)) = lit5.node
5677
&& let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind
5778
&& block1.expr.is_none()
5879
&& block.expr.is_none()

0 commit comments

Comments
 (0)