Name Resolution, Salsa Brainstorming
Goal: Make name resolution incremental

Queries

  • Name resolution results
  • Expansion of a macro

Scenario #1


// crate C0

lazy_static! { // ID L0
    static ref HASHMAP: HashMap<u32, &'static str> = {
        let mut m = HashMap::new();
        m.insert(0, "foo");
//        m.insert(1, "bar"); <-- change is to alter this line
        m.insert(2, "baz");
        m
    };
}

Concept

  • name_resolution_results(C0): Map<Identifier, Id>
  • fixed point process
  • to expand macro invocation L0 we have to figure out what lazy_static refers to
  • we use the map we are building, we get back the id of a definition D0
  • expand_macro_invocation(D0, L0) // source D0, arguments L0
  • but what are the arguments to this query — particularly the id of the **invocation**
  • challenge is that we need ids that can map to the result of expansion

  • what does the id map to
  • span in a concrete file
  • span into the result of a macro expansion (D0, L0)

  • recursive macro invocation:
  • macro A expands to b!(…)
  • expand_macro_invocation(a_def, a_use_site)
  • make an id (a_def, a_use_site) and call it b_use_site

  • name resolution
  • definitions_from_macro_invocation(a_def, a_use_site)
  • vec![b_use_site]
  • definitions_from_macro_invocation(b_def, b_use_site)