@@ -2,15 +2,17 @@ use clippy_utils::diagnostics::span_lint;
22use clippy_utils:: ty:: is_type_diagnostic_item;
33use rustc_hir:: Expr ;
44use rustc_lint:: LateContext ;
5- use rustc_span:: sym:: Result as sym_result ;
5+ use rustc_span:: sym;
66
77use super :: NEEDLESS_OPTION_TAKE ;
88
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);
1416 then {
1517 span_lint(
1618 cx,
@@ -19,5 +21,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'
1921 "Format test"
2022 );
2123 }
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 )
2330}
0 commit comments