Scope snippets within a crate

Use the same crate identifier for manually included snippets as well as
inline snippets to help with debugging.
This commit is contained in:
Alex Crichton
2019-03-05 14:53:14 -08:00
parent c463cc96df
commit d6e3770350
4 changed files with 56 additions and 21 deletions

View File

@ -78,7 +78,7 @@ impl Interner {
// Generate a unique ID which is somewhat readable as well, so mix in
// the crate name, hash to make it unique, and then the original path.
let new_identifier = format!("{}-{}{}", self.crate_name, ShortHash(0), id);
let new_identifier = format!("{}{}", self.unique_crate_identifier(), id);
let file = LocalFile {
path,
definition: span,
@ -88,6 +88,10 @@ impl Interner {
drop(files);
self.resolve_import_module(id, span)
}
fn unique_crate_identifier(&self) -> String {
format!("{}-{}", self.crate_name, ShortHash(0))
}
}
fn shared_program<'a>(
@ -139,6 +143,7 @@ fn shared_program<'a>(
.iter()
.map(|js| intern.intern_str(js))
.collect(),
unique_crate_identifier: intern.intern_str(&intern.unique_crate_identifier()),
})
}