@@ -26,8 +26,8 @@ impl<'hir> Item<'hir> {
2626 Self { hir_item, renamed_name, from_glob }
2727 }
2828
29- pub ( crate ) fn name ( & ' hir self ) -> & ' hir Symbol {
30- self . renamed_name . as_ref ( ) . unwrap_or ( & self . hir_item . ident . name )
29+ pub ( crate ) fn name ( & self ) -> Symbol {
30+ self . renamed_name . unwrap_or ( self . hir_item . ident . name )
3131 }
3232}
3333
@@ -44,7 +44,7 @@ crate struct Module<'hir> {
4444 /// whether the module is from a glob import
4545 /// if `from_glob` is true and we see another module with same name,
4646 /// then this item can be replaced with that one
47- pub ( crate ) from_glob : bool ,
47+ crate from_glob : bool ,
4848}
4949
5050impl Module < ' hir > {
@@ -64,34 +64,30 @@ impl Module<'hir> {
6464 }
6565
6666 pub ( crate ) fn push_item ( & mut self , new_item : Item < ' hir > ) {
67- if let Some ( existed_item ) =
67+ if let Some ( existing_item ) =
6868 self . items . iter_mut ( ) . find ( |item| item. name ( ) == new_item. name ( ) )
6969 {
70- if existed_item. name ( ) == new_item. name ( ) {
71- if existed_item. from_glob {
72- debug ! ( "push_item: {:?} shadowed by {:?}" , * existed_item, new_item) ;
73- * existed_item = new_item;
74- return ;
75- } else if new_item. from_glob {
76- return ;
77- }
70+ if existing_item. from_glob {
71+ debug ! ( "push_item: {:?} shadowed by {:?}" , * existing_item, new_item) ;
72+ * existing_item = new_item;
73+ return ;
74+ } else if new_item. from_glob {
75+ return ;
7876 }
79- } else {
80- self . items . push ( new_item) ;
8177 }
78+ self . items . push ( new_item) ;
8279 }
8380
8481 pub ( crate ) fn push_mod ( & mut self , new_item : Module < ' hir > ) {
85- if let Some ( existed_mod ) = self . mods . iter_mut ( ) . find ( |mod_| mod_. name == new_item. name ) {
86- if existed_mod . from_glob {
87- debug ! ( "push_mod: {:?} shadowed by {:?}" , existed_mod . name, new_item. name) ;
88- * existed_mod = new_item;
82+ if let Some ( existing_mod ) = self . mods . iter_mut ( ) . find ( |mod_| mod_. name == new_item. name ) {
83+ if existing_mod . from_glob {
84+ debug ! ( "push_mod: {:?} shadowed by {:?}" , existing_mod . name, new_item. name) ;
85+ * existing_mod = new_item;
8986 return ;
9087 } else if new_item. from_glob {
9188 return ;
9289 }
93- } else {
94- self . mods . push ( new_item) ;
9590 }
91+ self . mods . push ( new_item) ;
9692 }
9793}
0 commit comments