@@ -137,23 +137,6 @@ impl<'a> SingleImports<'a> {
137
137
}
138
138
139
139
impl < ' a > NameResolution < ' a > {
140
- fn try_define ( & mut self , binding : & ' a NameBinding < ' a > ) -> Result < ( ) , & ' a NameBinding < ' a > > {
141
- if let Some ( old_binding) = self . binding {
142
- if binding. is_glob_import ( ) {
143
- self . duplicate_globs . push ( binding) ;
144
- } else if old_binding. is_glob_import ( ) {
145
- self . duplicate_globs . push ( old_binding) ;
146
- self . binding = Some ( binding) ;
147
- } else {
148
- return Err ( old_binding) ;
149
- }
150
- } else {
151
- self . binding = Some ( binding) ;
152
- }
153
-
154
- Ok ( ( ) )
155
- }
156
-
157
140
// Returns the binding for the name if it is known or None if it not known.
158
141
fn binding ( & self ) -> Option < & ' a NameBinding < ' a > > {
159
142
self . binding . and_then ( |binding| match self . single_imports {
@@ -246,8 +229,22 @@ impl<'a> ::ModuleS<'a> {
246
229
// Define the name or return the existing binding if there is a collision.
247
230
pub fn try_define_child ( & self , name : Name , ns : Namespace , binding : NameBinding < ' a > )
248
231
-> Result < ( ) , & ' a NameBinding < ' a > > {
232
+ let binding = self . arenas . alloc_name_binding ( binding) ;
249
233
self . update_resolution ( name, ns, |resolution| {
250
- resolution. try_define ( self . arenas . alloc_name_binding ( binding) )
234
+ if let Some ( old_binding) = resolution. binding {
235
+ if binding. is_glob_import ( ) {
236
+ resolution. duplicate_globs . push ( binding) ;
237
+ } else if old_binding. is_glob_import ( ) {
238
+ resolution. duplicate_globs . push ( old_binding) ;
239
+ resolution. binding = Some ( binding) ;
240
+ } else {
241
+ return Err ( old_binding) ;
242
+ }
243
+ } else {
244
+ resolution. binding = Some ( binding) ;
245
+ }
246
+
247
+ Ok ( ( ) )
251
248
} )
252
249
}
253
250
0 commit comments