Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/name.rs')
-rw-r--r--crates/hir-expand/src/name.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/hir-expand/src/name.rs b/crates/hir-expand/src/name.rs
index cf17d90ed1..0b69799e6b 100644
--- a/crates/hir-expand/src/name.rs
+++ b/crates/hir-expand/src/name.rs
@@ -111,15 +111,11 @@ impl Name {
self == &Name::missing()
}
- /// Generates a new name which is only equal to itself, by incrementing a counter. Due
- /// its implementation, it should not be used in things that salsa considers, like
- /// type names or field names, and it should be only used in names of local variables
- /// and labels and similar things.
- pub fn generate_new_name() -> Name {
- use std::sync::atomic::{AtomicUsize, Ordering};
- static CNT: AtomicUsize = AtomicUsize::new(0);
- let c = CNT.fetch_add(1, Ordering::Relaxed);
- Name::new_text(format_smolstr!("<ra@gennew>{c}"))
+ /// Generates a new name that attempts to be unique. Should only be used when body lowering and
+ /// creating desugared locals and labels. The caller is responsible for picking an index
+ /// that is stable across re-executions
+ pub fn generate_new_name(idx: usize) -> Name {
+ Name::new_text(format_smolstr!("<ra@gennew>{idx}"))
}
/// Returns the tuple index this name represents if it is a tuple field.