Skip to content

Early Name Resolution: Imports #8

@yaahc

Description

@yaahc

tracking my progress on researching this part of name resolution and how it works. Including a copy of the daily personal notes I take on the subject

Outline

I'm going to keep this section up to date with the draft outline in my notes

  • Outline

    • names.resolution
      • .early
        • .intro
          • early name resolution is part of macro expansion and is necessary to fully generate the AST of a rust crate
            • should I even mention ASTs? explaining why it exists seems to necessarily go into implementation details
            • the AST is mentioned in other parts of the reference, including the macros section, so possibly this is fine
          • imports are resolved to assist in macro resolution
          • macros are resolved so they can be expanded
          • this process is iterative and repeats until no progress can be made (fixed point algorithm)
            • I think I might be able to include this but not mention how this means it's a fixed point algorithm
              - Post expansion these resolutions are checked again to ensure no new ambiguities were introduced by the expansion process
          • Note: This section seems to be largely related to implementation details, will probably need to trim it down to just the bits that are relevant to language, possibly just noting the relationship to macro expansion
        • .imports
          • .shadowing
          • .errors
            • .reserved-names
              id:: 68acc38b-20bd-4f49-99ad-92e98d136e7b
              • the names cfg and cfg_attr are reserved in the macro attribute sub-namespace
            • .ambiguity
              id:: 68acc63c-c157-4f82-9bf6-8f439017b1ed
              • BuiltinAttr
                • it is an error to have a user defined attribute or derive macro with the same name as a builtin attribute (e.g. inline)
              • DeriveHelper
                • derive helpers used before their associated derive may not shadow other attributes or other derive helpers that are otherwise in scope after their derive
              • MacroRulesVsModularized
                • path-based scope bindings for macros may not shadow textual scope bindings to macros
              • GlobVsOuter
                • it is an error to shadow an outer name binding with a glob import
              • GlobVsGlob
                • it is an error to name an item through ambiguous use declarations
                  id:: 68b0a2d7-52ce-462a-a166-f8e796a13aca
                  • two globs imports which both have an item matching that name where the items are different
                    id:: 68b0a2d7-e8c3-420a-87ee-b875f54e6e15
                    • this is still an error even if there is a third non glob binding resolution to an item with the same name
                • it is not an error to have two glob imports which include items which would be ambiguous so long as you do not name one of those items through the ambiguous glob imports
              • GlobVsExpanded
                • Grey Area
              • MoreExpandedVsOuter
                • it is an error for name bindings from macro expansions to shadow name bindings from outside of those expansions
          • shadowing and ambiguity may or may not represent the same section or one may be a subsection of the other
        • .macros
      • .late

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions