@@ -2,15 +2,17 @@ use clippy_utils::diagnostics::span_lint;
2
2
use clippy_utils:: ty:: is_type_diagnostic_item;
3
3
use rustc_hir:: Expr ;
4
4
use rustc_lint:: LateContext ;
5
- use rustc_span:: sym:: Result as sym_result ;
5
+ use rustc_span:: sym;
6
6
7
7
use super :: OPTION_TAKE_ON_TEMPORARY ;
8
8
9
- pub ( super ) fn check < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > , recv : & ' tcx Expr < ' _ > ) {
10
- if_chain ! {
11
- if is_type_diagnostic_item( cx, cx. typeck_results( ) . expr_ty( recv) , sym_result) ;
12
- let result_type = cx. typeck_results( ) . expr_ty( recv) ;
13
-
9
+ pub ( super ) fn check < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > , _recv : & ' tcx Expr < ' _ > ) {
10
+ // Checks if expression type is equal to sym::Option and if the expr is not a syntactic place
11
+ if is_expr_option ( cx, expr) & !expr. is_syntactic_place_expr ( ) {
12
+ span_lint ( cx, OPTION_TAKE_ON_TEMPORARY , expr. span , "Format test" ) ;
13
+ }
14
+ /* if_chain! {
15
+ is_expr_option(cx, expr);
14
16
then {
15
17
span_lint(
16
18
cx,
@@ -19,5 +21,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'
19
21
"Format test"
20
22
);
21
23
}
22
- } ;
24
+ };*/
25
+ }
26
+
27
+ fn is_expr_option ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
28
+ let expr_type = cx. typeck_results ( ) . expr_ty ( expr) ;
29
+ is_type_diagnostic_item ( cx, expr_type, sym:: Option )
23
30
}
0 commit comments