Add test gen for multimorphic capture

This commit is contained in:
Ayaz Hafiz 2022-06-28 17:26:42 -04:00 committed by ayazhafiz
parent 8be230695b
commit ada4b0ea43
No known key found for this signature in database
GPG key ID: B443F7A3030C9AED
3 changed files with 49 additions and 1 deletions

View file

@ -852,6 +852,16 @@ impl MultimorphicNames {
fn insert<'b>(&mut self, name: Symbol, captures_layouts: &'b [Layout<'b>]) -> Symbol {
self.0.lock().unwrap().insert(name, captures_layouts)
}
/// Assumes there is only one clone still alive.
/// If there is more than one clone alive, `self` is returned.
pub fn try_unwrap_names(self) -> Result<IdentIds, Self> {
let mutex = Arc::try_unwrap(self.0).map_err(Self)?;
let table = mutex
.into_inner()
.expect("how can there be another lock if we consumed the only ref?");
Ok(table.ident_ids)
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]