@@ -15,8 +15,7 @@ mod utils;
15
15
mod while_let_loop;
16
16
mod while_let_on_iterator;
17
17
18
- use crate :: utils:: sugg:: Sugg ;
19
- use crate :: utils:: { higher, sugg} ;
18
+ use crate :: utils:: higher;
20
19
use rustc_hir:: { Expr , ExprKind , LoopSource , Pat } ;
21
20
use rustc_lint:: { LateContext , LateLintPass } ;
22
21
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
@@ -596,73 +595,3 @@ fn check_for_loop<'tcx>(
596
595
same_item_push:: detect_same_item_push ( cx, pat, arg, body, expr) ;
597
596
manual_flatten:: check_manual_flatten ( cx, pat, arg, body, span) ;
598
597
}
599
-
600
- /// a wrapper of `Sugg`. Besides what `Sugg` do, this removes unnecessary `0`;
601
- /// and also, it avoids subtracting a variable from the same one by replacing it with `0`.
602
- /// it exists for the convenience of the overloaded operators while normal functions can do the
603
- /// same.
604
- #[ derive( Clone ) ]
605
- struct MinifyingSugg < ' a > ( Sugg < ' a > ) ;
606
-
607
- impl < ' a > MinifyingSugg < ' a > {
608
- fn as_str ( & self ) -> & str {
609
- let Sugg :: NonParen ( s) | Sugg :: MaybeParen ( s) | Sugg :: BinOp ( _, s) = & self . 0 ;
610
- s. as_ref ( )
611
- }
612
-
613
- fn into_sugg ( self ) -> Sugg < ' a > {
614
- self . 0
615
- }
616
- }
617
-
618
- impl < ' a > From < Sugg < ' a > > for MinifyingSugg < ' a > {
619
- fn from ( sugg : Sugg < ' a > ) -> Self {
620
- Self ( sugg)
621
- }
622
- }
623
-
624
- impl std:: ops:: Add for & MinifyingSugg < ' static > {
625
- type Output = MinifyingSugg < ' static > ;
626
- fn add ( self , rhs : & MinifyingSugg < ' static > ) -> MinifyingSugg < ' static > {
627
- match ( self . as_str ( ) , rhs. as_str ( ) ) {
628
- ( "0" , _) => rhs. clone ( ) ,
629
- ( _, "0" ) => self . clone ( ) ,
630
- ( _, _) => ( & self . 0 + & rhs. 0 ) . into ( ) ,
631
- }
632
- }
633
- }
634
-
635
- impl std:: ops:: Sub for & MinifyingSugg < ' static > {
636
- type Output = MinifyingSugg < ' static > ;
637
- fn sub ( self , rhs : & MinifyingSugg < ' static > ) -> MinifyingSugg < ' static > {
638
- match ( self . as_str ( ) , rhs. as_str ( ) ) {
639
- ( _, "0" ) => self . clone ( ) ,
640
- ( "0" , _) => ( -rhs. 0 . clone ( ) ) . into ( ) ,
641
- ( x, y) if x == y => sugg:: ZERO . into ( ) ,
642
- ( _, _) => ( & self . 0 - & rhs. 0 ) . into ( ) ,
643
- }
644
- }
645
- }
646
-
647
- impl std:: ops:: Add < & MinifyingSugg < ' static > > for MinifyingSugg < ' static > {
648
- type Output = MinifyingSugg < ' static > ;
649
- fn add ( self , rhs : & MinifyingSugg < ' static > ) -> MinifyingSugg < ' static > {
650
- match ( self . as_str ( ) , rhs. as_str ( ) ) {
651
- ( "0" , _) => rhs. clone ( ) ,
652
- ( _, "0" ) => self ,
653
- ( _, _) => ( self . 0 + & rhs. 0 ) . into ( ) ,
654
- }
655
- }
656
- }
657
-
658
- impl std:: ops:: Sub < & MinifyingSugg < ' static > > for MinifyingSugg < ' static > {
659
- type Output = MinifyingSugg < ' static > ;
660
- fn sub ( self , rhs : & MinifyingSugg < ' static > ) -> MinifyingSugg < ' static > {
661
- match ( self . as_str ( ) , rhs. as_str ( ) ) {
662
- ( _, "0" ) => self ,
663
- ( "0" , _) => ( -rhs. 0 . clone ( ) ) . into ( ) ,
664
- ( x, y) if x == y => sugg:: ZERO . into ( ) ,
665
- ( _, _) => ( self . 0 - & rhs. 0 ) . into ( ) ,
666
- }
667
- }
668
- }
0 commit comments