@@ -111,7 +111,7 @@ use clippy_utils::ty::{contains_ty_adt_constructor_opaque, implements_trait, is_
111111use clippy_utils:: { contains_return, is_bool, is_trait_method, iter_input_pats, return_ty} ;
112112use if_chain:: if_chain;
113113use rustc_hir as hir;
114- use rustc_hir:: { Expr , ExprKind , TraitItem , TraitItemKind } ;
114+ use rustc_hir:: { Expr , ExprKind , Node , Stmt , StmtKind , TraitItem , TraitItemKind } ;
115115use rustc_hir_analysis:: hir_ty_to_ty;
116116use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
117117use rustc_middle:: lint:: in_external_macro;
@@ -3590,7 +3590,13 @@ impl Methods {
35903590 _ => { } ,
35913591 } ,
35923592 ( "drain" , [ arg] ) => {
3593- iter_with_drain:: check ( cx, expr, recv, span, arg) ;
3593+ if let Node :: Stmt ( Stmt { hir_id : _, kind, .. } ) = cx. tcx . hir ( ) . get_parent ( expr. hir_id )
3594+ && matches ! ( kind, StmtKind :: Semi ( _) )
3595+ {
3596+ clear_with_drain:: check ( cx, expr, recv, span, arg) ;
3597+ } else {
3598+ iter_with_drain:: check ( cx, expr, recv, span, arg) ;
3599+ }
35943600 } ,
35953601 ( "ends_with" , [ arg] ) => {
35963602 if let ExprKind :: MethodCall ( .., span) = expr. kind {
0 commit comments