conlang: Use interned strings (Sym) for all symbols

This commit is contained in:
2024-04-24 19:34:29 -05:00
parent ede00c3c86
commit 40ec9b30e4
19 changed files with 198 additions and 195 deletions

View File

@@ -131,9 +131,6 @@ fn list_types(prj: &mut Project) {
println!(" name\x1b[30G type");
for (idx, Def { name, vis, kind, .. }) in prj.pool.iter().enumerate() {
print!("{idx:3}: {vis}");
if name.is_empty() {
print!("\x1b[30m_\x1b[0m")
}
println!("{name}\x1b[30G| {kind}");
}
}

View File

@@ -35,16 +35,16 @@ pub enum DefSource<'a> {
}
impl<'a> DefSource<'a> {
pub fn name(&self) -> Option<&'a str> {
pub fn name(&self) -> Option<Sym> {
match self {
DefSource::Module(v) => Some(v.name.0.as_str()),
DefSource::Alias(v) => Some(v.to.0.as_str()),
DefSource::Enum(v) => Some(v.name.0.as_str()),
DefSource::Struct(v) => Some(v.name.0.as_str()),
DefSource::Const(v) => Some(v.name.0.as_str()),
DefSource::Static(v) => Some(v.name.0.as_str()),
DefSource::Function(v) => Some(v.name.0.as_str()),
DefSource::Local(l) => Some(l.name.0.as_str()),
DefSource::Module(v) => Some(v.name.0),
DefSource::Alias(v) => Some(v.to.0),
DefSource::Enum(v) => Some(v.name.0),
DefSource::Struct(v) => Some(v.name.0),
DefSource::Const(v) => Some(v.name.0),
DefSource::Static(v) => Some(v.name.0),
DefSource::Function(v) => Some(v.name.0),
DefSource::Local(l) => Some(l.name.0),
DefSource::Impl(_) | DefSource::Use(_) | DefSource::Ty(_) => None,
}
}

View File

@@ -1,24 +1,24 @@
use crate::{key::DefID, module::Module};
use cl_ast::{Item, Meta, Visibility};
use cl_ast::{Item, Meta, Sym, Visibility};
use std::{fmt::Debug, str::FromStr};
mod display;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Def<'a> {
pub name: &'a str,
pub name: Sym,
pub vis: Visibility,
pub meta: &'a [Meta],
pub kind: DefKind<'a>,
pub kind: DefKind,
pub source: Option<&'a Item>,
pub module: Module<'a>,
pub module: Module,
}
mod builder_functions {
use super::*;
impl<'a> Def<'a> {
pub fn set_name(&mut self, name: &'a str) -> &mut Self {
pub fn set_name(&mut self, name: Sym) -> &mut Self {
self.name = name;
self
}
@@ -30,7 +30,7 @@ mod builder_functions {
self.meta = meta;
self
}
pub fn set_kind(&mut self, kind: DefKind<'a>) -> &mut Self {
pub fn set_kind(&mut self, kind: DefKind) -> &mut Self {
self.kind = kind;
self
}
@@ -38,7 +38,7 @@ mod builder_functions {
self.source = Some(source);
self
}
pub fn set_module(&mut self, module: Module<'a>) -> &mut Self {
pub fn set_module(&mut self, module: Module) -> &mut Self {
self.module = module;
self
}
@@ -48,7 +48,7 @@ mod builder_functions {
impl Default for Def<'_> {
fn default() -> Self {
Self {
name: Default::default(),
name: "".into(),
vis: Visibility::Public,
meta: Default::default(),
kind: Default::default(),
@@ -59,7 +59,7 @@ impl Default for Def<'_> {
}
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub enum DefKind<'a> {
pub enum DefKind {
/// An unevaluated definition
#[default]
Undecided,
@@ -68,7 +68,7 @@ pub enum DefKind<'a> {
/// A use tree, and its parent
Use(DefID),
/// A type, such as a `type`, `struct`, or `enum`
Type(TypeKind<'a>),
Type(TypeKind),
/// A value, such as a `const`, `static`, or `fn`
Value(ValueKind),
}
@@ -84,13 +84,13 @@ pub enum ValueKind {
/// A [TypeKind] represents an item in the Type Namespace
/// (a component of a [Project](crate::project::Project)).
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum TypeKind<'a> {
pub enum TypeKind {
/// An alias for an already-defined type
Alias(Option<DefID>),
/// A primitive type, built-in to the compiler
Intrinsic(Intrinsic),
/// A user-defined aromatic data type
Adt(Adt<'a>),
Adt(Adt),
/// A reference to an already-defined type: &T
Ref(u16, DefID),
/// A contiguous view of dynamically sized memory
@@ -113,16 +113,16 @@ pub enum TypeKind<'a> {
/// A user-defined Aromatic Data Type
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Adt<'a> {
pub enum Adt {
/// A union-like enum type
Enum(Vec<(&'a str, Option<DefID>)>),
Enum(Vec<(Sym, Option<DefID>)>),
/// A C-like enum
CLikeEnum(Vec<(&'a str, u128)>),
CLikeEnum(Vec<(Sym, u128)>),
/// An enum with no fields, which can never be constructed
FieldlessEnum,
/// A structural product type with named members
Struct(Vec<(&'a str, Visibility, DefID)>),
Struct(Vec<(Sym, Visibility, DefID)>),
/// A structural product type with unnamed members
TupleStruct(Vec<(Visibility, DefID)>),
/// A structural product type of neither named nor unnamed members
@@ -130,7 +130,7 @@ pub enum Adt<'a> {
/// A choose your own undefined behavior type
/// TODO: should unions be a language feature?
Union(Vec<(&'a str, DefID)>),
Union(Vec<(Sym, DefID)>),
}
/// The set of compiler-intrinsic types.

View File

@@ -44,7 +44,7 @@ impl Display for Def<'_> {
}
}
impl Display for DefKind<'_> {
impl Display for DefKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DefKind::Undecided => write!(f, "undecided"),
@@ -66,7 +66,7 @@ impl std::fmt::Display for ValueKind {
}
}
impl Display for TypeKind<'_> {
impl Display for TypeKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TypeKind::Alias(def) => match def {
@@ -99,7 +99,7 @@ impl Display for TypeKind<'_> {
}
}
impl Display for Adt<'_> {
impl Display for Adt {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Adt::Enum(variants) => {

View File

@@ -1,5 +1,6 @@
//! A [Module] is a node in the Module Tree (a component of a
//! [Project](crate::project::Project))
use cl_ast::Sym;
use cl_structures::intern_pool::InternKey;
use crate::key::DefID;
@@ -8,14 +9,14 @@ use std::collections::HashMap;
/// A [Module] is a node in the Module Tree (a component of a
/// [Project](crate::project::Project)).
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Module<'a> {
pub struct Module {
pub parent: Option<DefID>,
pub types: HashMap<&'a str, DefID>,
pub values: HashMap<&'a str, DefID>,
pub types: HashMap<Sym, DefID>,
pub values: HashMap<Sym, DefID>,
pub imports: Vec<DefID>,
}
impl<'a> Module<'a> {
impl Module {
pub fn new(parent: DefID) -> Self {
Self { parent: Some(parent), ..Default::default() }
}
@@ -23,29 +24,29 @@ impl<'a> Module<'a> {
Self { parent, ..Default::default() }
}
pub fn get(&self, name: &'a str) -> (Option<DefID>, Option<DefID>) {
pub fn get(&self, name: Sym) -> (Option<DefID>, Option<DefID>) {
(self.get_type(name), self.get_value(name))
}
pub fn get_type(&self, name: &'a str) -> Option<DefID> {
self.types.get(name).copied()
pub fn get_type(&self, name: Sym) -> Option<DefID> {
self.types.get(&name).copied()
}
pub fn get_value(&self, name: &'a str) -> Option<DefID> {
self.values.get(name).copied()
pub fn get_value(&self, name: Sym) -> Option<DefID> {
self.values.get(&name).copied()
}
/// Inserts a type with the provided [name](str) and [id](DefID)
pub fn insert_type(&mut self, name: &'a str, id: DefID) -> Option<DefID> {
pub fn insert_type(&mut self, name: Sym, id: DefID) -> Option<DefID> {
self.types.insert(name, id)
}
/// Inserts a value with the provided [name](str) and [id](DefID)
pub fn insert_value(&mut self, name: &'a str, id: DefID) -> Option<DefID> {
pub fn insert_value(&mut self, name: Sym, id: DefID) -> Option<DefID> {
self.values.insert(name, id)
}
}
impl std::fmt::Display for Module<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl std::fmt::Display for Module {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let Self { parent, types, values, imports } = self;
if let Some(parent) = parent {
writeln!(f, "Parent: {}", parent.get())?;

View File

@@ -50,8 +50,8 @@ impl<'a> NameCollectable<'a> for Module {
let Self { name: Identifier(name), kind } = self;
let module =
c.pool
.insert(Def { name, module: Mod::new(parent), ..Default::default() });
c[parent].module.types.insert(name, module);
.insert(Def { name: *name, module: Mod::new(parent), ..Default::default() });
c[parent].module.types.insert(*name, module);
match kind {
ModuleKind::Inline(file) => file.collect(c, module)?,
@@ -87,10 +87,10 @@ impl<'a> NameCollectable<'a> for Alias {
fn collect(&'a self, c: &mut Prj<'a>, parent: DefID) -> Result<DefID, &'static str> {
let Alias { to: Identifier(name), .. } = self;
let def = Def { name, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.types.insert(name, id);
c[parent].module.types.insert(*name, id);
Ok(id)
}
}
@@ -98,10 +98,10 @@ impl<'a> NameCollectable<'a> for Enum {
fn collect(&'a self, c: &mut Prj<'a>, parent: DefID) -> Result<DefID, &'static str> {
let Enum { name: Identifier(name), .. } = self;
let def = Def { name, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.types.insert(name, id);
c[parent].module.types.insert(*name, id);
Ok(id)
}
}
@@ -109,10 +109,10 @@ impl<'a> NameCollectable<'a> for Struct {
fn collect(&'a self, c: &mut Prj<'a>, parent: DefID) -> Result<DefID, &'static str> {
let Struct { name: Identifier(name), .. } = self;
let def = Def { name, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.types.insert(name, id);
c[parent].module.types.insert(*name, id);
Ok(id)
}
}
@@ -122,10 +122,10 @@ impl<'a> NameCollectable<'a> for Const {
let kind = DefKind::Undecided;
let def = Def { name, kind, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, kind, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.values.insert(name, id);
c[parent].module.values.insert(*name, id);
init.collect(c, id)?;
Ok(id)
@@ -137,10 +137,10 @@ impl<'a> NameCollectable<'a> for Static {
let kind = DefKind::Undecided;
let def = Def { name, kind, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, kind, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.values.insert(name, id);
c[parent].module.values.insert(*name, id);
init.collect(c, id)?;
Ok(id)
@@ -152,10 +152,10 @@ impl<'a> NameCollectable<'a> for Function {
let kind = DefKind::Undecided;
let def = Def { name, kind, module: Mod::new(parent), ..Default::default() };
let def = Def { name: *name, kind, module: Mod::new(parent), ..Default::default() };
let id = c.pool.insert(def);
c[parent].module.values.insert(name, id);
c[parent].module.values.insert(*name, id);
body.collect(c, id)?;
Ok(id)

View File

@@ -18,7 +18,7 @@ use self::evaluate::EvaluableTypeExpression;
pub struct Project<'a> {
pub pool: Pool<Def<'a>, DefID>,
/// Stores anonymous tuples, function pointer types, etc.
pub anon_types: HashMap<TypeKind<'a>, DefID>,
pub anon_types: HashMap<TypeKind, DefID>,
pub root: DefID,
}
@@ -32,21 +32,21 @@ impl Default for Project<'_> {
fn default() -> Self {
let mut pool = Pool::default();
let root = pool.insert(Def {
name: "🌳 root 🌳",
name: "🌳 root 🌳".into(),
kind: DefKind::Type(TypeKind::Module),
..Default::default()
});
// Insert the Never(!) type
let never = pool.insert(Def {
name: "!",
name: "!".into(),
vis: Visibility::Public,
kind: DefKind::Type(TypeKind::Never),
module: module::Module::new(root),
..Default::default()
});
let empty = pool.insert(Def {
name: "()",
name: "()".into(),
vis: Visibility::Public,
kind: DefKind::Type(TypeKind::Empty),
module: module::Module::new(root),
@@ -54,7 +54,7 @@ impl Default for Project<'_> {
});
// TODO: Self is not a real type!
let selfty = pool.insert(Def {
name: "Self",
name: "Self".into(),
vis: Visibility::Public,
kind: DefKind::Type(TypeKind::SelfTy),
module: module::Module::new(root),
@@ -92,11 +92,11 @@ impl<'a> Project<'a> {
match path.as_ref() {
[] => Some((Some(within), None, path)),
[PathPart::Ident(Identifier(name))] => {
let (ty, val) = self[within].module.get(name);
let (ty, val) = self[within].module.get(*name);
Some((ty, val, path.pop_front()?))
}
[PathPart::Ident(Identifier(name)), ..] => {
let ty = self[within].module.get_type(name)?;
let ty = self[within].module.get_type(*name)?;
self.get(path.pop_front()?, ty)
}
[PathPart::SelfKw, ..] => self.get(path.pop_front()?, within),
@@ -114,7 +114,7 @@ impl<'a> Project<'a> {
match front {
PathPart::SelfKw => self.get_type(path.pop_front()?, within),
PathPart::SuperKw => self.get_type(path.pop_front()?, module.parent?),
PathPart::Ident(Identifier(name)) => match module.types.get(name.as_str()) {
PathPart::Ident(Identifier(name)) => match module.types.get(name) {
Some(&submodule) => self.get_type(path.pop_front()?, submodule),
None => Some((within, path)),
},
@@ -127,7 +127,7 @@ impl<'a> Project<'a> {
pub fn get_value<'p>(&self, path: Path<'p>, within: DefID) -> Option<(DefID, Path<'p>)> {
match path.front()? {
PathPart::Ident(Identifier(name)) => Some((
self[within].module.values.get(name.as_str()).copied()?,
self[within].module.values.get(name).copied()?,
path.pop_front()?,
)),
_ => None,
@@ -139,7 +139,7 @@ impl<'a> Project<'a> {
/// Assumes `kind` uniquely identifies the type!
pub fn insert_anonymous_type(
&mut self,
kind: TypeKind<'a>,
kind: TypeKind,
def: impl FnOnce() -> Def<'a>,
) -> DefID {
*(self
@@ -171,7 +171,7 @@ pub mod evaluate {
//! or an intermediate result of expression evaluation.
use super::*;
use cl_ast::Ty;
use cl_ast::{Sym, Ty};
/// Things that can be evaluated as a type expression
pub trait EvaluableTypeExpression {
@@ -203,8 +203,7 @@ pub mod evaluate {
if path.is_empty() {
id
} else {
let (id, path) =
prj.get_value(path, id).ok_or("Failed to get value")?;
let (id, path) = prj.get_value(path, id).ok_or("Failed to get value")?;
path.is_empty()
.then_some(id)
.ok_or("Path not fully resolved")?
@@ -220,7 +219,7 @@ pub mod evaluate {
}
}
impl EvaluableTypeExpression for str {
impl EvaluableTypeExpression for Sym {
type Out = DefID;
fn evaluate(&self, prj: &mut Project, parent: DefID) -> Result<Self::Out, String> {
@@ -298,7 +297,7 @@ pub mod evaluate {
.parent_of(parent)
.ok_or_else(|| "Attempt to get super of root".into()),
PathPart::SelfKw => Ok(parent),
PathPart::Ident(Identifier(name)) => name.as_str().evaluate(prj, parent),
PathPart::Ident(Identifier(name)) => name.evaluate(prj, parent),
}
}
}

View File

@@ -45,7 +45,7 @@ pub trait TypeResolvable<'a> {
}
impl<'a> TypeResolvable<'a> for Item {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let Self { attrs: Attrs { meta }, kind, .. } = self;
for meta in meta {
@@ -58,11 +58,12 @@ impl<'a> TypeResolvable<'a> for Item {
}
impl<'a> TypeResolvable<'a> for Meta {
type Out = DefKind<'a>;
type Out = DefKind;
#[allow(unused_variables)]
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let Self { name: Identifier(name), kind } = self;
let name = name.get().unwrap_or_default();
match (name.as_str(), kind) {
("intrinsic", MetaKind::Equals(Literal::String(intrinsic))) => Ok(DefKind::Type(
TypeKind::Intrinsic(intrinsic.parse().map_err(|_| "unknown intrinsic type")?),
@@ -76,7 +77,7 @@ impl<'a> TypeResolvable<'a> for Meta {
}
impl<'a> TypeResolvable<'a> for ItemKind {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
if prj[id].source.map(|s| &s.kind as *const _) != Some(self as *const _) {
return Err("id is not self!");
@@ -96,7 +97,7 @@ impl<'a> TypeResolvable<'a> for ItemKind {
}
impl<'a> TypeResolvable<'a> for Module {
type Out = DefKind<'a>;
type Out = DefKind;
#[allow(unused_variables)]
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
Ok(DefKind::Type(TypeKind::Module))
@@ -104,7 +105,7 @@ impl<'a> TypeResolvable<'a> for Module {
}
impl<'a> TypeResolvable<'a> for Impl {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);
@@ -122,7 +123,7 @@ impl<'a> TypeResolvable<'a> for Impl {
}
impl<'a> TypeResolvable<'a> for Use {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
todo!("Resolve types for {self} with ID {id} in {prj:?}")
@@ -130,7 +131,7 @@ impl<'a> TypeResolvable<'a> for Use {
}
impl<'a> TypeResolvable<'a> for Alias {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);
@@ -149,7 +150,7 @@ impl<'a> TypeResolvable<'a> for Alias {
}
impl<'a> TypeResolvable<'a> for Enum {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let Self { name: _, kind } = self;
@@ -159,7 +160,7 @@ impl<'a> TypeResolvable<'a> for Enum {
let mut fields = vec![];
for v @ Variant { name: Identifier(name), kind: _ } in v {
let id = v.resolve_type(prj, id)?;
fields.push((name.as_str(), id))
fields.push((*name, id))
}
Ok(DefKind::Type(TypeKind::Adt(Adt::Enum(fields))))
}
@@ -185,7 +186,7 @@ impl<'a> TypeResolvable<'a> for Variant {
};
let def = Def {
name,
name: *name,
kind: DefKind::Type(TypeKind::Adt(adt)),
module: module::Module::new(id),
..Default::default()
@@ -193,14 +194,14 @@ impl<'a> TypeResolvable<'a> for Variant {
let new_id = prj.pool.insert(def);
// Insert the struct variant type into the enum's namespace
prj[id].module.types.insert(name, new_id);
prj[id].module.types.insert(*name, new_id);
Ok(Some(new_id))
}
}
impl<'a> TypeResolvable<'a> for Struct {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);
let Self { name: _, kind } = self;
@@ -225,7 +226,7 @@ impl<'a> TypeResolvable<'a> for Struct {
}
impl<'a> TypeResolvable<'a> for StructMember {
type Out = (&'a str, Visibility, DefID);
type Out = (Sym, Visibility, DefID);
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);
@@ -235,12 +236,12 @@ impl<'a> TypeResolvable<'a> for StructMember {
.evaluate(prj, parent)
.map_err(|_| "Invalid type while resolving StructMember")?;
Ok((name, *vis, ty))
Ok((*name, *vis, ty))
}
}
impl<'a> TypeResolvable<'a> for Const {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let Self { ty, .. } = self;
@@ -251,7 +252,7 @@ impl<'a> TypeResolvable<'a> for Const {
}
}
impl<'a> TypeResolvable<'a> for Static {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);
@@ -264,7 +265,7 @@ impl<'a> TypeResolvable<'a> for Static {
}
impl<'a> TypeResolvable<'a> for Function {
type Out = DefKind<'a>;
type Out = DefKind;
fn resolve_type(&'a self, prj: &mut Prj<'a>, id: DefID) -> Result<Self::Out, &'static str> {
let parent = prj.parent_of(id).unwrap_or(id);

View File

@@ -1,5 +1,5 @@
//! WIP use-item importer. This performs eager import resolution on the AST
//!
//!
//! # TODOs:
//! - [ ] Resolve imports using a graph traversal rather than linear iteration
//! - [ ] Separate imported items from natively declared items
@@ -7,7 +7,6 @@
//! - [ ] Report errors in a meaningful way
//! - [ ] Lazy import resolution using graph-edge traversal during name lookup?
//! - It doesn't seem to me like the imports in a given scope *can change*.
//!
#![allow(unused)]
use std::fmt::format;
@@ -74,20 +73,15 @@ impl<'a> Project<'a> {
Ok(())
}
pub fn visit_use_leaf(
&mut self,
part: &'a Identifier,
parent: DefID,
c: DefID,
) -> UseResult {
pub fn visit_use_leaf(&mut self, part: &'a Identifier, parent: DefID, c: DefID) -> UseResult {
let Identifier(name) = part;
self.visit_use_alias(name, name, parent, c)
}
pub fn visit_use_alias(
&mut self,
from: &'a str,
name: &'a str,
from: &Sym,
name: &Sym,
parent: DefID,
c: DefID,
) -> UseResult {
@@ -100,12 +94,12 @@ impl<'a> Project<'a> {
let parent = &mut self[parent].module;
if let Some(tid) = tid {
parent.types.insert(name, tid);
parent.types.insert(*name, tid);
imported = true;
}
if let Some(vid) = vid {
parent.values.insert(name, vid);
parent.values.insert(*name, vid);
imported = true;
}