@@ -14,10 +14,8 @@ use if_chain::if_chain;
14
14
use rustc_ast:: ast;
15
15
use rustc_errors:: Applicability ;
16
16
use rustc_hir as hir;
17
- use rustc_hir:: intravisit:: { self , Visitor } ;
18
17
use rustc_hir:: { TraitItem , TraitItemKind } ;
19
18
use rustc_lint:: { LateContext , LateLintPass , Lint , LintContext } ;
20
- use rustc_middle:: hir:: map:: Map ;
21
19
use rustc_middle:: lint:: in_external_macro;
22
20
use rustc_middle:: ty:: { self , TraitRef , Ty , TyS } ;
23
21
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -28,11 +26,12 @@ use crate::consts::{constant, Constant};
28
26
use crate :: utils:: eager_or_lazy:: is_lazyness_candidate;
29
27
use crate :: utils:: usage:: mutated_variables;
30
28
use crate :: utils:: {
31
- contains_ty, get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, higher, implements_trait, in_macro,
32
- is_copy, is_expn_of, is_type_diagnostic_item, iter_input_pats, last_path_segment, match_def_path, match_qpath,
33
- match_trait_method, match_type, match_var, meets_msrv, method_calls, method_chain_args, paths, remove_blocks,
34
- return_ty, single_segment_path, snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint,
35
- span_lint_and_help, span_lint_and_sugg, span_lint_and_then, sugg, walk_ptrs_ty_depth, SpanlessEq ,
29
+ contains_return, contains_ty, get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, higher,
30
+ implements_trait, in_macro, is_copy, is_expn_of, is_type_diagnostic_item, iter_input_pats, last_path_segment,
31
+ match_def_path, match_qpath, match_trait_method, match_type, match_var, meets_msrv, method_calls,
32
+ method_chain_args, paths, remove_blocks, return_ty, single_segment_path, snippet, snippet_with_applicability,
33
+ snippet_with_macro_callsite, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then, sugg,
34
+ walk_ptrs_ty_depth, SpanlessEq ,
36
35
} ;
37
36
use semver:: { Version , VersionReq } ;
38
37
@@ -3877,36 +3876,6 @@ fn is_bool(ty: &hir::Ty<'_>) -> bool {
3877
3876
}
3878
3877
}
3879
3878
3880
- // Returns `true` if `expr` contains a return expression
3881
- fn contains_return ( expr : & hir:: Expr < ' _ > ) -> bool {
3882
- struct RetCallFinder {
3883
- found : bool ,
3884
- }
3885
-
3886
- impl < ' tcx > intravisit:: Visitor < ' tcx > for RetCallFinder {
3887
- type Map = Map < ' tcx > ;
3888
-
3889
- fn visit_expr ( & mut self , expr : & ' tcx hir:: Expr < ' _ > ) {
3890
- if self . found {
3891
- return ;
3892
- }
3893
- if let hir:: ExprKind :: Ret ( ..) = & expr. kind {
3894
- self . found = true ;
3895
- } else {
3896
- intravisit:: walk_expr ( self , expr) ;
3897
- }
3898
- }
3899
-
3900
- fn nested_visit_map ( & mut self ) -> intravisit:: NestedVisitorMap < Self :: Map > {
3901
- intravisit:: NestedVisitorMap :: None
3902
- }
3903
- }
3904
-
3905
- let mut visitor = RetCallFinder { found : false } ;
3906
- visitor. visit_expr ( expr) ;
3907
- visitor. found
3908
- }
3909
-
3910
3879
fn check_pointer_offset ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) {
3911
3880
if_chain ! {
3912
3881
if args. len( ) == 2 ;
0 commit comments