@@ -7,8 +7,6 @@ use std::cell::Cell;
77#[ cfg( feature = "logging" ) ]
88use std:: cell:: RefCell ;
99use std:: fmt:: { self , Write } ;
10- #[ cfg( feature = "logging" ) ]
11- use std:: error:: Error ;
1210use std:: hash:: { Hash , Hasher } ;
1311use std:: mem;
1412use std:: ops;
@@ -27,10 +25,10 @@ thread_local! {
2725
2826impl AutoLogParse {
2927 #[ cfg( feature = "logging" ) ]
30- fn new < ' a > ( production : & ' static str , input : IndexStr < ' a > ) -> AutoLogParse {
28+ fn new ( production : & ' static str , input : IndexStr < ' _ > ) -> AutoLogParse {
3129 LOG_DEPTH . with ( |depth| {
3230 if * depth. borrow ( ) == 0 {
33- println ! ( "" ) ;
31+ println ! ( ) ;
3432 }
3533
3634 let indent: String = ( 0 ..* depth. borrow ( ) * 4 ) . map ( |_| ' ' ) . collect ( ) ;
@@ -93,7 +91,7 @@ impl AutoLogDemangle {
9391 {
9492 LOG_DEPTH . with ( |depth| {
9593 if * depth. borrow ( ) == 0 {
96- println ! ( "" ) ;
94+ println ! ( ) ;
9795 }
9896
9997 let indent: String = ( 0 ..* depth. borrow ( ) * 4 ) . map ( |_| ' ' ) . collect ( ) ;
@@ -575,7 +573,7 @@ where
575573 pub fn new (
576574 subs : & ' a SubstitutionTable ,
577575 input : & ' a [ u8 ] ,
578- options : & DemangleOptions ,
576+ options : DemangleOptions ,
579577 out : & ' a mut W ,
580578 ) -> DemangleContext < ' a , W > {
581579 DemangleContext {
@@ -656,13 +654,12 @@ where
656654
657655 #[ inline]
658656 fn pop_inner_if ( & mut self , inner : & ' a dyn DemangleAsInner < ' a , W > ) -> bool {
659- if {
660- let last = match self . inner . last ( ) {
661- None => return false ,
662- Some ( last) => * last,
663- } ;
664- ptr:: eq ( last, inner)
665- } {
657+ let last = match self . inner . last ( ) {
658+ None => return false ,
659+ Some ( last) => * last,
660+ } ;
661+
662+ if ptr:: eq ( last, inner) {
666663 self . inner . pop ( ) ;
667664 true
668665 } else {
@@ -890,7 +887,7 @@ macro_rules! reference_newtype {
890887 struct $newtype_name( $oldtype) ;
891888
892889 impl $newtype_name {
893- #[ allow( ptr_arg) ]
890+ #[ allow( clippy :: ptr_arg) ]
894891 #[ allow( unsafe_code) ]
895892 fn new( types: & $oldtype) -> & $newtype_name {
896893 unsafe {
@@ -899,7 +896,7 @@ macro_rules! reference_newtype {
899896 // requirements. An immutable reference does not allow
900897 // dropping the referent, so no worries about double-free
901898 // (additionally, see the assertion inside `Drop` below).
902- mem :: transmute ( types)
899+ & * ( types as * const $oldtype as * const $newtype_name )
903900 }
904901 }
905902 }
@@ -997,7 +994,7 @@ where
997994 ctx. demangle_inner_prefixes ( scope) ?;
998995
999996 if needs_paren {
1000- write ! ( ctx, "{}" , ')' ) ?;
997+ write ! ( ctx, ")" ) ?;
1001998 }
1002999
10031000 write ! ( ctx, "(" ) ?;
@@ -1424,7 +1421,7 @@ where
14241421 Encoding :: Function ( ref name, ref fun_ty) => {
14251422 // Even if this function takes no args and doesn't have a return
14261423 // value (see below), it will have the void parameter.
1427- debug_assert ! ( fun_ty. 0 . len ( ) >= 1 ) ;
1424+ debug_assert ! ( ! fun_ty. 0 . is_empty ( ) ) ;
14281425
14291426 let scope = if let Some ( leaf) = name. get_leaf_name ( ctx. subs ) {
14301427 match leaf {
@@ -1938,7 +1935,7 @@ impl Parse for NestedName {
19381935 NestedName :: Template ( cv_qualifiers, ref_qualifier, prefix) ,
19391936 tail,
19401937 ) ) ,
1941- _ => return Err ( error:: Error :: UnexpectedText ) ,
1938+ _ => Err ( error:: Error :: UnexpectedText ) ,
19421939 }
19431940 }
19441941}
@@ -2109,10 +2106,10 @@ impl Parse for PrefixHandle {
21092106 try_begin_parse ! ( "PrefixHandle" , ctx, input) ;
21102107
21112108 #[ inline]
2112- fn save < ' a , ' b > (
2113- subs : & ' a mut SubstitutionTable ,
2109+ fn save (
2110+ subs : & mut SubstitutionTable ,
21142111 prefix : Prefix ,
2115- tail_tail : IndexStr < ' b > ,
2112+ tail_tail : IndexStr < ' _ > ,
21162113 ) -> PrefixHandle {
21172114 if let Some ( b'E' ) = tail_tail. peek ( ) {
21182115 // An `E` means that we just finished parsing a `<nested-name>`
@@ -3385,6 +3382,7 @@ impl CtorDtorName {
33853382/// ::= <substitution>
33863383/// ```
33873384#[ derive( Clone , Debug , PartialEq , Eq ) ]
3385+ #[ allow( clippy:: large_enum_variant) ]
33883386pub enum Type {
33893387 /// A function type.
33903388 Function ( FunctionType ) ,
@@ -5058,7 +5056,9 @@ where
50585056 if need_comma {
50595057 write ! ( ctx, ", " ) ?;
50605058 }
5061- scope. as_mut ( ) . map ( |scope| scope. in_arg = Some ( ( arg_index, self ) ) ) ;
5059+ if let Some ( ref mut scope) = scope {
5060+ scope. in_arg = Some ( ( arg_index, self ) ) ;
5061+ }
50625062 self . 0 [ arg_index] . demangle ( ctx, scope) ?;
50635063 need_comma = true ;
50645064 }
@@ -7628,7 +7628,7 @@ mod tests {
76287628 String :: from_utf8_lossy( expected_tail)
76297629 ) ;
76307630 }
7631- if & subs[ ..] != & expected_subs[ ..] {
7631+ if subs[ ..] != expected_subs[ ..] {
76327632 panic ! (
76337633 "Parsing {:?} as {} produced a substitutions table of\n \n \
76347634 {:#?}\n \n \
0 commit comments