1111use self :: ImportDirectiveSubclass :: * ;
1212
1313use { AmbiguityError , AmbiguityKind , AmbiguityErrorMisc } ;
14- use { CrateLint , DeterminacyExt , Module , ModuleOrUniformRoot , PerNS , UniformRootKind } ;
14+ use { CrateLint , Module , ModuleOrUniformRoot , PerNS , UniformRootKind , Weak } ;
1515use Namespace :: { self , TypeNS , MacroNS } ;
1616use { NameBinding , NameBindingKind , ToNameBinding , PathResult , PrivacyError } ;
1717use Resolver ;
@@ -145,7 +145,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
145145 ) -> Result < & ' a NameBinding < ' a > , Determinacy > {
146146 self . resolve_ident_in_module_unadjusted_ext (
147147 module, ident, ns, None , false , record_used, path_span
148- ) . map_err ( DeterminacyExt :: to_determinacy )
148+ ) . map_err ( | ( determinacy , _ ) | determinacy )
149149 }
150150
151151 /// Attempts to resolve `ident` in namespaces `ns` of `module`.
@@ -159,7 +159,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
159159 restricted_shadowing : bool ,
160160 record_used : bool ,
161161 path_span : Span ,
162- ) -> Result < & ' a NameBinding < ' a > , DeterminacyExt > {
162+ ) -> Result < & ' a NameBinding < ' a > , ( Determinacy , Weak ) > {
163163 let module = match module {
164164 ModuleOrUniformRoot :: Module ( module) => module,
165165 ModuleOrUniformRoot :: UniformRoot ( uniform_root_kind) => {
@@ -171,9 +171,9 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
171171 Ok ( binding)
172172 } else if !self . graph_root . unresolved_invocations . borrow ( ) . is_empty ( ) {
173173 // Macro-expanded `extern crate` items can add names to extern prelude.
174- Err ( DeterminacyExt :: Undetermined )
174+ Err ( ( Undetermined , Weak :: No ) )
175175 } else {
176- Err ( DeterminacyExt :: Determined )
176+ Err ( ( Determined , Weak :: No ) )
177177 }
178178 }
179179 UniformRootKind :: CurrentScope => {
@@ -198,10 +198,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
198198 let binding = self . early_resolve_ident_in_lexical_scope (
199199 ident, ns, None , true , parent_scope, record_used, record_used, path_span
200200 ) ;
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 ) ) ;
205202 }
206203 }
207204 }
@@ -211,8 +208,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
211208
212209 let resolution = self . resolution ( module, ident, ns)
213210 . 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.
216212
217213 if let Some ( binding) = resolution. binding {
218214 if !restricted_shadowing && binding. expansion != Mark :: root ( ) {
@@ -226,13 +222,13 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
226222 // `extern crate` are always usable for backwards compatibility, see issue #37020,
227223 // remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`.
228224 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 ) ) }
230226 } ;
231227
232228 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| {
234230 if self . last_import_segment && check_usable ( self , binding) . is_err ( ) {
235- Err ( DeterminacyExt :: Determined )
231+ Err ( ( Determined , Weak :: No ) )
236232 } else {
237233 self . record_use ( ident, ns, binding, restricted_shadowing) ;
238234
@@ -279,7 +275,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
279275 continue ;
280276 }
281277 let module = unwrap_or ! ( single_import. imported_module. get( ) ,
282- return Err ( DeterminacyExt :: Undetermined ) ) ;
278+ return Err ( ( Undetermined , Weak :: No ) ) ) ;
283279 let ident = match single_import. subclass {
284280 SingleImport { source, .. } => source,
285281 _ => unreachable ! ( ) ,
@@ -290,7 +286,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
290286 Ok ( binding) if !self . is_accessible_from (
291287 binding. vis , single_import. parent_scope . module
292288 ) => continue ,
293- Ok ( _) | Err ( Undetermined ) => return Err ( DeterminacyExt :: Undetermined ) ,
289+ Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: No ) ) ,
294290 }
295291 }
296292
@@ -311,7 +307,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
311307 if !unexpanded_macros || ns == MacroNS || restricted_shadowing {
312308 return check_usable ( self , binding) ;
313309 } else {
314- return Err ( DeterminacyExt :: Undetermined ) ;
310+ return Err ( ( Undetermined , Weak :: No ) ) ;
315311 }
316312 }
317313
@@ -321,12 +317,12 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
321317 // expansion. With restricted shadowing names from globs and macro expansions cannot
322318 // shadow names from outer scopes, so we can freely fallback from module search to search
323319 // 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 `.
325321
326322 // Check if one of unexpanded macros can still define the name,
327323 // if it can then our "no resolution" result is not determined and can be invalidated.
328324 if unexpanded_macros {
329- return Err ( DeterminacyExt :: WeakUndetermined ) ;
325+ return Err ( ( Undetermined , Weak :: Yes ) ) ;
330326 }
331327
332328 // Check if one of glob imports can still define the name,
@@ -338,7 +334,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
338334 let module = match glob_import. imported_module . get ( ) {
339335 Some ( ModuleOrUniformRoot :: Module ( module) ) => module,
340336 Some ( ModuleOrUniformRoot :: UniformRoot ( _) ) => continue ,
341- None => return Err ( DeterminacyExt :: WeakUndetermined ) ,
337+ None => return Err ( ( Undetermined , Weak :: Yes ) ) ,
342338 } ;
343339 let ( orig_current_module, mut ident) = ( self . current_module , ident. modern ( ) ) ;
344340 match ident. span . glob_adjust ( module. expansion , glob_import. span . ctxt ( ) . modern ( ) ) {
@@ -360,12 +356,12 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
360356 Ok ( binding) if !self . is_accessible_from (
361357 binding. vis , glob_import. parent_scope . module
362358 ) => continue ,
363- Ok ( _) | Err ( Undetermined ) => return Err ( DeterminacyExt :: WeakUndetermined ) ,
359+ Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
364360 }
365361 }
366362
367363 // No resolution and no one else can define the name - determinate error.
368- Err ( DeterminacyExt :: Determined )
364+ Err ( ( Determined , Weak :: No ) )
369365 }
370366
371367 // Add an import directive to the current module.
0 commit comments