@@ -14,10 +14,8 @@ use if_chain::if_chain;
1414use rustc_ast:: ast;
1515use rustc_errors:: Applicability ;
1616use rustc_hir as hir;
17- use rustc_hir:: intravisit:: { self , Visitor } ;
1817use rustc_hir:: { TraitItem , TraitItemKind } ;
1918use rustc_lint:: { LateContext , LateLintPass , Lint , LintContext } ;
20- use rustc_middle:: hir:: map:: Map ;
2119use rustc_middle:: lint:: in_external_macro;
2220use rustc_middle:: ty:: { self , TraitRef , Ty , TyS } ;
2321use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -28,11 +26,12 @@ use crate::consts::{constant, Constant};
2826use crate :: utils:: eager_or_lazy:: is_lazyness_candidate;
2927use crate :: utils:: usage:: mutated_variables;
3028use 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 ,
3635} ;
3736use semver:: { Version , VersionReq } ;
3837
@@ -3877,36 +3876,6 @@ fn is_bool(ty: &hir::Ty<'_>) -> bool {
38773876 }
38783877}
38793878
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-
39103879fn check_pointer_offset ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) {
39113880 if_chain ! {
39123881 if args. len( ) == 2 ;
0 commit comments