# HG changeset patch # User Simon Heath # Date 1736722311 18000 # Sun Jan 12 17:51:51 2025 -0500 # Branch devel # Node ID 3b4c96fa40a9347f39bba4b613950fb53ddf55a5 # Parent 1c0036922cf3790174211941ede557a66a952803 grmbl grmbl symbol tables diff --git a/src/hir2/lower.rs b/src/hir2/lower.rs --- a/src/hir2/lower.rs +++ b/src/hir2/lower.rs @@ -23,6 +23,16 @@ } } +/// See crate::symtbl::UniqueSym. +/// +/// Rust is a silly language sometimes. +impl Default for Idx { + fn default() -> Self { + unreachable!( + "can't happen, but we want to be able to default-construct containers containing this" + ) + } +} fn lower_lit(lit: &ast::Literal) -> Literal { lit.clone() } @@ -679,6 +689,7 @@ #[derive(Default)] struct IndexRenamer { next_var_idx: usize, + symtbl: crate::symtbl::Symtbl, } impl super::visit::Visit for IndexRenamer { @@ -970,8 +981,6 @@ let ir = lower(&ast); let mut ctr = IndexRenamer::default(); ctr.visit(&ir); - assert_eq!(ctr.vars, varcount); - assert_eq!(ctr.type_vars, typevarcount); } } } diff --git a/src/symtbl.rs b/src/symtbl.rs --- a/src/symtbl.rs +++ b/src/symtbl.rs @@ -29,10 +29,18 @@ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct UniqueSym(pub Sym); +impl Default for UniqueSym { + fn default() -> Self { + unreachable!( + "can't happen, but we want to be able to default-construct containers containing this" + ) + } +} + #[derive(Clone, Default, Debug)] -struct ScopeFrame { - symbols: BTreeMap, - types: BTreeMap, +struct ScopeFrame { + symbols: BTreeMap, + types: BTreeMap, } /// A shortcut for a cloneable AnyMap @@ -42,8 +50,8 @@ /// and manages scope. /// Looks ugly, works well. #[derive(Debug, Clone)] -pub struct Symtbl { - frames: Rc>>, +pub struct Symtbl { + frames: Rc>>>, /// A mapping from unique symbol names to whatever /// we need to know about them. It's an AnyMap, so /// we can just stuff whatever data we need into it.