@@ -297,60 +297,6 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) {
297297 }
298298}
299299
300- fn check_powi ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , args : & [ Expr < ' _ > ] ) {
301- if let Some ( ( value, _) ) = constant ( cx, cx. typeck_results ( ) , & args[ 1 ] ) {
302- if value == Int ( 2 ) {
303- if let Some ( parent) = get_parent_expr ( cx, expr) {
304- if let Some ( grandparent) = get_parent_expr ( cx, parent) {
305- if let ExprKind :: MethodCall ( PathSegment { ident : method_name, .. } , _, args, _) = grandparent. kind {
306- if method_name. as_str ( ) == "sqrt" && detect_hypot ( cx, args) . is_some ( ) {
307- return ;
308- }
309- }
310- }
311-
312- if let ExprKind :: Binary (
313- Spanned {
314- node : BinOpKind :: Add , ..
315- } ,
316- lhs,
317- rhs,
318- ) = parent. kind
319- {
320- let other_addend = if lhs. hir_id == expr. hir_id { rhs } else { lhs } ;
321-
322- span_lint_and_sugg (
323- cx,
324- SUBOPTIMAL_FLOPS ,
325- parent. span ,
326- "square can be computed more efficiently" ,
327- "consider using" ,
328- format ! (
329- "{}.mul_add({}, {})" ,
330- Sugg :: hir( cx, & args[ 0 ] , ".." ) ,
331- Sugg :: hir( cx, & args[ 0 ] , ".." ) ,
332- Sugg :: hir( cx, other_addend, ".." ) ,
333- ) ,
334- Applicability :: MachineApplicable ,
335- ) ;
336-
337- return ;
338- }
339- }
340-
341- span_lint_and_sugg (
342- cx,
343- SUBOPTIMAL_FLOPS ,
344- expr. span ,
345- "square can be computed more efficiently" ,
346- "consider using" ,
347- format ! ( "{} * {}" , Sugg :: hir( cx, & args[ 0 ] , ".." ) , Sugg :: hir( cx, & args[ 0 ] , ".." ) ) ,
348- Applicability :: MachineApplicable ,
349- ) ;
350- }
351- }
352- }
353-
354300fn detect_hypot ( cx : & LateContext < ' _ > , args : & [ Expr < ' _ > ] ) -> Option < String > {
355301 if let ExprKind :: Binary (
356302 Spanned {
@@ -706,7 +652,6 @@ impl<'tcx> LateLintPass<'tcx> for FloatingPointArithmetic {
706652 "ln" => check_ln1p ( cx, expr, args) ,
707653 "log" => check_log_base ( cx, expr, args) ,
708654 "powf" => check_powf ( cx, expr, args) ,
709- "powi" => check_powi ( cx, expr, args) ,
710655 "sqrt" => check_hypot ( cx, expr, args) ,
711656 _ => { } ,
712657 }
0 commit comments