@@ -2,7 +2,7 @@ use rustc::lint::*;
2
2
use rustc:: hir;
3
3
use rustc:: ty;
4
4
use syntax_pos:: Span ;
5
- use crate :: utils:: { match_def_path, method_chain_args, span_lint_and_then, walk_ptrs_ty, is_expn_of} ;
5
+ use crate :: utils:: { match_def_path, method_chain_args, span_lint_and_then, walk_ptrs_ty, is_expn_of, opt_def_id } ;
6
6
use crate :: utils:: paths:: { BEGIN_PANIC , BEGIN_PANIC_FMT , FROM_TRAIT , OPTION , RESULT } ;
7
7
8
8
/// **What it does:** Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`
@@ -65,8 +65,9 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
65
65
if_chain ! {
66
66
if let ExprCall ( ref func_expr, _) = expr. node;
67
67
if let ExprPath ( QPath :: Resolved ( _, ref path) ) = func_expr. node;
68
- if match_def_path( self . tcx, path. def. def_id( ) , & BEGIN_PANIC ) ||
69
- match_def_path( self . tcx, path. def. def_id( ) , & BEGIN_PANIC_FMT ) ;
68
+ if let Some ( path_def_id) = opt_def_id( path. def) ;
69
+ if match_def_path( self . tcx, path_def_id, & BEGIN_PANIC ) ||
70
+ match_def_path( self . tcx, path_def_id, & BEGIN_PANIC_FMT ) ;
70
71
if is_expn_of( expr. span, "unreachable" ) . is_none( ) ;
71
72
then {
72
73
self . result. push( expr. span) ;
0 commit comments