11
11
use self :: ImportDirectiveSubclass :: * ;
12
12
13
13
use { AmbiguityError , AmbiguityKind , AmbiguityErrorMisc } ;
14
- use { CrateLint , DeterminacyExt , Module , ModuleOrUniformRoot , PerNS , UniformRootKind } ;
14
+ use { CrateLint , Module , ModuleOrUniformRoot , PerNS , UniformRootKind , Weak } ;
15
15
use Namespace :: { self , TypeNS , MacroNS } ;
16
16
use { NameBinding , NameBindingKind , ToNameBinding , PathResult , PrivacyError } ;
17
17
use Resolver ;
@@ -145,7 +145,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
145
145
) -> Result < & ' a NameBinding < ' a > , Determinacy > {
146
146
self . resolve_ident_in_module_unadjusted_ext (
147
147
module, ident, ns, None , false , record_used, path_span
148
- ) . map_err ( DeterminacyExt :: to_determinacy )
148
+ ) . map_err ( | ( determinacy , _ ) | determinacy )
149
149
}
150
150
151
151
/// Attempts to resolve `ident` in namespaces `ns` of `module`.
@@ -159,7 +159,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
159
159
restricted_shadowing : bool ,
160
160
record_used : bool ,
161
161
path_span : Span ,
162
- ) -> Result < & ' a NameBinding < ' a > , DeterminacyExt > {
162
+ ) -> Result < & ' a NameBinding < ' a > , ( Determinacy , Weak ) > {
163
163
let module = match module {
164
164
ModuleOrUniformRoot :: Module ( module) => module,
165
165
ModuleOrUniformRoot :: UniformRoot ( uniform_root_kind) => {
@@ -171,9 +171,9 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
171
171
Ok ( binding)
172
172
} else if !self . graph_root . unresolved_invocations . borrow ( ) . is_empty ( ) {
173
173
// Macro-expanded `extern crate` items can add names to extern prelude.
174
- Err ( DeterminacyExt :: Undetermined )
174
+ Err ( ( Undetermined , Weak :: No ) )
175
175
} else {
176
- Err ( DeterminacyExt :: Determined )
176
+ Err ( ( Determined , Weak :: No ) )
177
177
}
178
178
}
179
179
UniformRootKind :: CurrentScope => {
@@ -198,10 +198,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
198
198
let binding = self . early_resolve_ident_in_lexical_scope (
199
199
ident, ns, None , true , parent_scope, record_used, record_used, path_span
200
200
) ;
201
- return binding. map_err ( |determinacy| match determinacy {
202
- Determined => DeterminacyExt :: Determined ,
203
- Undetermined => DeterminacyExt :: Undetermined ,
204
- } ) ;
201
+ return binding. map_err ( |determinacy| ( determinacy, Weak :: No ) ) ;
205
202
}
206
203
}
207
204
}
@@ -211,8 +208,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
211
208
212
209
let resolution = self . resolution ( module, ident, ns)
213
210
. try_borrow_mut ( )
214
- // This happens when there is a cycle of imports.
215
- . map_err ( |_| DeterminacyExt :: Determined ) ?;
211
+ . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
216
212
217
213
if let Some ( binding) = resolution. binding {
218
214
if !restricted_shadowing && binding. expansion != Mark :: root ( ) {
@@ -226,13 +222,13 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
226
222
// `extern crate` are always usable for backwards compatibility, see issue #37020,
227
223
// remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`.
228
224
let usable = this. is_accessible ( binding. vis ) || binding. is_extern_crate ( ) ;
229
- if usable { Ok ( binding) } else { Err ( DeterminacyExt :: Determined ) }
225
+ if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
230
226
} ;
231
227
232
228
if record_used {
233
- return resolution. binding . ok_or ( DeterminacyExt :: Determined ) . and_then ( |binding| {
229
+ return resolution. binding . ok_or ( ( Determined , Weak :: No ) ) . and_then ( |binding| {
234
230
if self . last_import_segment && check_usable ( self , binding) . is_err ( ) {
235
- Err ( DeterminacyExt :: Determined )
231
+ Err ( ( Determined , Weak :: No ) )
236
232
} else {
237
233
self . record_use ( ident, ns, binding, restricted_shadowing) ;
238
234
@@ -279,7 +275,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
279
275
continue ;
280
276
}
281
277
let module = unwrap_or ! ( single_import. imported_module. get( ) ,
282
- return Err ( DeterminacyExt :: Undetermined ) ) ;
278
+ return Err ( ( Undetermined , Weak :: No ) ) ) ;
283
279
let ident = match single_import. subclass {
284
280
SingleImport { source, .. } => source,
285
281
_ => unreachable ! ( ) ,
@@ -290,7 +286,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
290
286
Ok ( binding) if !self . is_accessible_from (
291
287
binding. vis , single_import. parent_scope . module
292
288
) => continue ,
293
- Ok ( _) | Err ( Undetermined ) => return Err ( DeterminacyExt :: Undetermined ) ,
289
+ Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: No ) ) ,
294
290
}
295
291
}
296
292
@@ -311,7 +307,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
311
307
if !unexpanded_macros || ns == MacroNS || restricted_shadowing {
312
308
return check_usable ( self , binding) ;
313
309
} else {
314
- return Err ( DeterminacyExt :: Undetermined ) ;
310
+ return Err ( ( Undetermined , Weak :: No ) ) ;
315
311
}
316
312
}
317
313
@@ -321,12 +317,12 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
321
317
// expansion. With restricted shadowing names from globs and macro expansions cannot
322
318
// shadow names from outer scopes, so we can freely fallback from module search to search
323
319
// in outer scopes. For `early_resolve_ident_in_lexical_scope` to continue search in outer
324
- // scopes we return `WeakUndetermined` instead of full `Undetermined `.
320
+ // scopes we return `Undetermined` with `Weak::Yes `.
325
321
326
322
// Check if one of unexpanded macros can still define the name,
327
323
// if it can then our "no resolution" result is not determined and can be invalidated.
328
324
if unexpanded_macros {
329
- return Err ( DeterminacyExt :: WeakUndetermined ) ;
325
+ return Err ( ( Undetermined , Weak :: Yes ) ) ;
330
326
}
331
327
332
328
// Check if one of glob imports can still define the name,
@@ -338,7 +334,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
338
334
let module = match glob_import. imported_module . get ( ) {
339
335
Some ( ModuleOrUniformRoot :: Module ( module) ) => module,
340
336
Some ( ModuleOrUniformRoot :: UniformRoot ( _) ) => continue ,
341
- None => return Err ( DeterminacyExt :: WeakUndetermined ) ,
337
+ None => return Err ( ( Undetermined , Weak :: Yes ) ) ,
342
338
} ;
343
339
let ( orig_current_module, mut ident) = ( self . current_module , ident. modern ( ) ) ;
344
340
match ident. span . glob_adjust ( module. expansion , glob_import. span . ctxt ( ) . modern ( ) ) {
@@ -360,12 +356,12 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
360
356
Ok ( binding) if !self . is_accessible_from (
361
357
binding. vis , glob_import. parent_scope . module
362
358
) => continue ,
363
- Ok ( _) | Err ( Undetermined ) => return Err ( DeterminacyExt :: WeakUndetermined ) ,
359
+ Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
364
360
}
365
361
}
366
362
367
363
// No resolution and no one else can define the name - determinate error.
368
- Err ( DeterminacyExt :: Determined )
364
+ Err ( ( Determined , Weak :: No ) )
369
365
}
370
366
371
367
// Add an import directive to the current module.
0 commit comments