@@ -417,19 +417,17 @@ impl<'a> Resolver<'a> {
417417 }
418418
419419 assert ! ( force || !record_used) ; // `record_used` implies `force`
420- let ident = orig_ident. modern ( ) ;
421420
422421 // Make sure `self`, `super` etc produce an error when passed to here.
423- if ident . is_path_segment_keyword ( ) {
422+ if orig_ident . is_path_segment_keyword ( ) {
424423 return Err ( Determinacy :: Determined ) ;
425424 }
426425
427- let rust_2015 = orig_ident. span . rust_2015 ( ) ;
428- let ( ns, macro_kind, is_import, is_absolute_path) = match scope_set {
429- ScopeSet :: Import ( ns) => ( ns, None , true , false ) ,
430- ScopeSet :: AbsolutePath ( ns) => ( ns, None , false , true ) ,
431- ScopeSet :: Macro ( macro_kind) => ( MacroNS , Some ( macro_kind) , false , false ) ,
432- ScopeSet :: Module => ( TypeNS , None , false , false ) ,
426+ let ( ns, macro_kind, is_import) = match scope_set {
427+ ScopeSet :: Import ( ns) => ( ns, None , true ) ,
428+ ScopeSet :: AbsolutePath ( ns) => ( ns, None , false ) ,
429+ ScopeSet :: Macro ( macro_kind) => ( MacroNS , Some ( macro_kind) , false ) ,
430+ ScopeSet :: Module => ( TypeNS , None , false ) ,
433431 } ;
434432
435433 // This is *the* result, resolution from the scope closest to the resolved identifier.
@@ -444,11 +442,11 @@ impl<'a> Resolver<'a> {
444442 // So we have to save the innermost solution and continue searching in outer scopes
445443 // to detect potential ambiguities.
446444 let mut innermost_result: Option < ( & NameBinding < ' _ > , Flags ) > = None ;
447- let mut use_prelude = !parent_scope. module . no_implicit_prelude ;
448445 let mut determinacy = Determinacy :: Determined ;
449446
450447 // Go through all the scopes and try to resolve the name.
451- let break_result = self . visit_scopes ( scope_set, parent_scope, ident, |this, scope, ident| {
448+ let break_result =
449+ self . visit_scopes ( scope_set, parent_scope, orig_ident, |this, scope, ident| {
452450 let result = match scope {
453451 Scope :: DeriveHelpers => {
454452 let mut result = Err ( Determinacy :: Determined ) ;
@@ -478,11 +476,11 @@ impl<'a> Resolver<'a> {
478476 _ => Err ( Determinacy :: Determined ) ,
479477 }
480478 Scope :: CrateRoot => {
481- let root_ident = Ident :: new ( kw:: PathRoot , orig_ident . span ) ;
479+ let root_ident = Ident :: new ( kw:: PathRoot , ident . span ) ;
482480 let root_module = this. resolve_crate_root ( root_ident) ;
483481 let binding = this. resolve_ident_in_module_ext (
484482 ModuleOrUniformRoot :: Module ( root_module) ,
485- orig_ident ,
483+ ident ,
486484 ns,
487485 None ,
488486 record_used,
@@ -498,7 +496,6 @@ impl<'a> Resolver<'a> {
498496 }
499497 }
500498 Scope :: Module ( module) => {
501- use_prelude = !module. no_implicit_prelude ;
502499 let orig_current_module = mem:: replace ( & mut this. current_module , module) ;
503500 let binding = this. resolve_ident_in_module_unadjusted_ext (
504501 ModuleOrUniformRoot :: Module ( module) ,
@@ -528,94 +525,69 @@ impl<'a> Resolver<'a> {
528525 Err ( ( Determinacy :: Determined , _) ) => Err ( Determinacy :: Determined ) ,
529526 }
530527 }
531- Scope :: MacroUsePrelude => {
532- if use_prelude || rust_2015 {
533- match this. macro_use_prelude . get ( & ident. name ) . cloned ( ) {
534- Some ( binding) =>
535- Ok ( ( binding, Flags :: PRELUDE | Flags :: MISC_FROM_PRELUDE ) ) ,
536- None => Err ( Determinacy :: determined (
537- this. graph_root . unresolved_invocations . borrow ( ) . is_empty ( )
538- ) )
539- }
540- } else {
541- Err ( Determinacy :: Determined )
542- }
528+ Scope :: MacroUsePrelude => match this. macro_use_prelude . get ( & ident. name ) . cloned ( ) {
529+ Some ( binding) => Ok ( ( binding, Flags :: PRELUDE | Flags :: MISC_FROM_PRELUDE ) ) ,
530+ None => Err ( Determinacy :: determined (
531+ this. graph_root . unresolved_invocations . borrow ( ) . is_empty ( )
532+ ) )
543533 }
544- Scope :: BuiltinMacros => {
545- match this. builtin_macros . get ( & ident. name ) . cloned ( ) {
546- Some ( binding) => Ok ( ( binding, Flags :: PRELUDE ) ) ,
547- None => Err ( Determinacy :: Determined ) ,
548- }
534+ Scope :: BuiltinMacros => match this. builtin_macros . get ( & ident. name ) . cloned ( ) {
535+ Some ( binding) => Ok ( ( binding, Flags :: PRELUDE ) ) ,
536+ None => Err ( Determinacy :: Determined ) ,
549537 }
550- Scope :: BuiltinAttrs => {
551- if is_builtin_attr_name ( ident. name ) {
552- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: Builtin ) ,
553- ty:: Visibility :: Public , DUMMY_SP , Mark :: root ( ) )
554- . to_name_binding ( this. arenas ) ;
555- Ok ( ( binding, Flags :: PRELUDE ) )
556- } else {
557- Err ( Determinacy :: Determined )
558- }
538+ Scope :: BuiltinAttrs => if is_builtin_attr_name ( ident. name ) {
539+ let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: Builtin ) ,
540+ ty:: Visibility :: Public , DUMMY_SP , Mark :: root ( ) )
541+ . to_name_binding ( this. arenas ) ;
542+ Ok ( ( binding, Flags :: PRELUDE ) )
543+ } else {
544+ Err ( Determinacy :: Determined )
559545 }
560- Scope :: LegacyPluginHelpers => {
561- if ( use_prelude || rust_2015) &&
562- this. session . plugin_attributes . borrow ( ) . iter ( )
546+ Scope :: LegacyPluginHelpers => if this. session . plugin_attributes . borrow ( ) . iter ( )
563547 . any ( |( name, _) | ident. name == * name) {
564- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: LegacyPluginHelper ) ,
565- ty:: Visibility :: Public , DUMMY_SP , Mark :: root ( ) )
566- . to_name_binding ( this. arenas ) ;
567- Ok ( ( binding, Flags :: PRELUDE ) )
568- } else {
569- Err ( Determinacy :: Determined )
570- }
548+ let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: LegacyPluginHelper ) ,
549+ ty:: Visibility :: Public , DUMMY_SP , Mark :: root ( ) )
550+ . to_name_binding ( this. arenas ) ;
551+ Ok ( ( binding, Flags :: PRELUDE ) )
552+ } else {
553+ Err ( Determinacy :: Determined )
571554 }
572- Scope :: ExternPrelude => {
573- if use_prelude || is_absolute_path {
574- match this. extern_prelude_get ( ident, !record_used) {
575- Some ( binding) => Ok ( ( binding, Flags :: PRELUDE ) ) ,
576- None => Err ( Determinacy :: determined (
577- this. graph_root . unresolved_invocations . borrow ( ) . is_empty ( )
578- ) ) ,
579- }
580- } else {
581- Err ( Determinacy :: Determined )
582- }
555+ Scope :: ExternPrelude => match this. extern_prelude_get ( ident, !record_used) {
556+ Some ( binding) => Ok ( ( binding, Flags :: PRELUDE ) ) ,
557+ None => Err ( Determinacy :: determined (
558+ this. graph_root . unresolved_invocations . borrow ( ) . is_empty ( )
559+ ) ) ,
583560 }
584- Scope :: ToolPrelude => {
585- if use_prelude && KNOWN_TOOLS . contains ( & ident. name ) {
586- let binding = ( Res :: ToolMod , ty:: Visibility :: Public ,
587- DUMMY_SP , Mark :: root ( ) ) . to_name_binding ( this. arenas ) ;
588- Ok ( ( binding, Flags :: PRELUDE ) )
589- } else {
590- Err ( Determinacy :: Determined )
591- }
561+ Scope :: ToolPrelude => if KNOWN_TOOLS . contains ( & ident. name ) {
562+ let binding = ( Res :: ToolMod , ty:: Visibility :: Public , DUMMY_SP , Mark :: root ( ) )
563+ . to_name_binding ( this. arenas ) ;
564+ Ok ( ( binding, Flags :: PRELUDE ) )
565+ } else {
566+ Err ( Determinacy :: Determined )
592567 }
593568 Scope :: StdLibPrelude => {
594569 let mut result = Err ( Determinacy :: Determined ) ;
595- if use_prelude {
596- if let Some ( prelude) = this. prelude {
597- if let Ok ( binding) = this. resolve_ident_in_module_unadjusted (
598- ModuleOrUniformRoot :: Module ( prelude) ,
599- ident,
600- ns,
601- false ,
602- path_span,
603- ) {
604- result = Ok ( ( binding, Flags :: PRELUDE | Flags :: MISC_FROM_PRELUDE ) ) ;
605- }
570+ if let Some ( prelude) = this. prelude {
571+ if let Ok ( binding) = this. resolve_ident_in_module_unadjusted (
572+ ModuleOrUniformRoot :: Module ( prelude) ,
573+ ident,
574+ ns,
575+ false ,
576+ path_span,
577+ ) {
578+ result = Ok ( ( binding, Flags :: PRELUDE | Flags :: MISC_FROM_PRELUDE ) ) ;
606579 }
607580 }
608581 result
609582 }
610- Scope :: BuiltinTypes => {
611- match this. primitive_type_table . primitive_types . get ( & ident. name ) . cloned ( ) {
612- Some ( prim_ty) => {
613- let binding = ( Res :: PrimTy ( prim_ty) , ty:: Visibility :: Public ,
614- DUMMY_SP , Mark :: root ( ) ) . to_name_binding ( this. arenas ) ;
615- Ok ( ( binding, Flags :: PRELUDE ) )
616- }
617- None => Err ( Determinacy :: Determined )
583+ Scope :: BuiltinTypes => match this. primitive_type_table . primitive_types
584+ . get ( & ident. name ) . cloned ( ) {
585+ Some ( prim_ty) => {
586+ let binding = ( Res :: PrimTy ( prim_ty) , ty:: Visibility :: Public ,
587+ DUMMY_SP , Mark :: root ( ) ) . to_name_binding ( this. arenas ) ;
588+ Ok ( ( binding, Flags :: PRELUDE ) )
618589 }
590+ None => Err ( Determinacy :: Determined )
619591 }
620592 } ;
621593
@@ -712,7 +684,7 @@ impl<'a> Resolver<'a> {
712684 // the last segment, so we are certainly working with a single-segment attribute here.)
713685 assert ! ( ns == MacroNS ) ;
714686 let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: Custom ) ,
715- ty:: Visibility :: Public , ident . span , Mark :: root ( ) )
687+ ty:: Visibility :: Public , orig_ident . span , Mark :: root ( ) )
716688 . to_name_binding ( self . arenas ) ;
717689 Ok ( binding)
718690 } else {
0 commit comments