1
+ mod utils;
2
+
1
3
use rustc_errors:: Applicability ;
2
4
use rustc_hir as hir;
3
5
use rustc_hir:: { BinOpKind , Block , Expr , ExprKind , MatchSource , Node , Stmt , StmtKind } ;
4
6
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
5
7
use rustc_middle:: lint:: in_external_macro;
6
- use rustc_middle:: ty:: { self , Ty } ;
7
8
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
8
9
use rustc_span:: hygiene:: { ExpnKind , MacroKind } ;
9
10
@@ -13,6 +14,8 @@ use crate::utils::diagnostics::{span_lint, span_lint_and_then};
13
14
use crate :: utils:: higher;
14
15
use crate :: utils:: source:: { indent_of, reindent_multiline, snippet_opt, snippet_with_macro_callsite} ;
15
16
17
+ use utils:: { is_unit, is_unit_literal} ;
18
+
16
19
declare_clippy_lint ! {
17
20
/// **What it does:** Checks for binding a unit value.
18
21
///
@@ -244,14 +247,6 @@ fn is_questionmark_desugar_marked_call(expr: &Expr<'_>) -> bool {
244
247
}
245
248
}
246
249
247
- fn is_unit ( ty : Ty < ' _ > ) -> bool {
248
- matches ! ( ty. kind( ) , ty:: Tuple ( slice) if slice. is_empty( ) )
249
- }
250
-
251
- fn is_unit_literal ( expr : & Expr < ' _ > ) -> bool {
252
- matches ! ( expr. kind, ExprKind :: Tup ( ref slice) if slice. is_empty( ) )
253
- }
254
-
255
250
fn lint_unit_args ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , args_to_recover : & [ & Expr < ' _ > ] ) {
256
251
let mut applicability = Applicability :: MachineApplicable ;
257
252
let ( singular, plural) = if args_to_recover. len ( ) > 1 {
0 commit comments