diff --git a/compiler/noirc_frontend/src/hir/printer/items.rs b/compiler/noirc_frontend/src/hir/printer/items.rs
index dc7aa9434ac..4bf69342e1a 100644
--- a/compiler/noirc_frontend/src/hir/printer/items.rs
+++ b/compiler/noirc_frontend/src/hir/printer/items.rs
@@ -93,7 +93,7 @@ pub struct TraitImpl {
pub external_types: bool,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Import {
pub name: Ident,
pub id: ModuleDefId,
diff --git a/tooling/nargo_doc/src/items.rs b/tooling/nargo_doc/src/items.rs
index 5153542832e..f33aaf49218 100644
--- a/tooling/nargo_doc/src/items.rs
+++ b/tooling/nargo_doc/src/items.rs
@@ -91,7 +91,7 @@ pub type Links = Vec;
pub type Comments = (String, Links);
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Workspace {
pub name: String,
/// Crates directly defined in this workspace.
@@ -106,7 +106,7 @@ impl Workspace {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Crate {
pub name: String,
pub version: Option,
@@ -128,7 +128,7 @@ impl ItemProperties for Crate {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum Item {
Module(Module),
Struct(Struct),
@@ -155,7 +155,7 @@ impl Item {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Module {
pub id: ItemId,
pub module_id: ModuleId,
@@ -185,7 +185,7 @@ impl ItemProperties for Module {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Struct {
pub id: ItemId,
pub name: String,
@@ -213,7 +213,7 @@ impl ItemProperties for Struct {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct StructField {
pub name: String,
pub r#type: Type,
@@ -234,14 +234,14 @@ impl ItemProperties for StructField {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Impl {
pub generics: Vec,
pub r#type: Type,
pub methods: Vec,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TraitImpl {
pub generics: Vec,
pub trait_id: ItemId,
@@ -252,7 +252,7 @@ pub struct TraitImpl {
pub methods: Vec,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Global {
pub id: ItemId,
pub name: String,
@@ -276,7 +276,7 @@ impl ItemProperties for Global {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Function {
pub id: ItemId,
pub unconstrained: bool,
@@ -304,14 +304,14 @@ impl ItemProperties for Function {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct FunctionParam {
pub name: String,
pub r#type: Type,
pub mut_ref: bool,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Trait {
pub id: ItemId,
pub name: String,
@@ -326,13 +326,13 @@ pub struct Trait {
pub comments: Option,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct AssociatedType {
pub name: String,
pub bounds: Vec,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct AssociatedConstant {
pub name: String,
pub r#type: Type,
@@ -352,7 +352,7 @@ impl ItemProperties for Trait {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TypeAlias {
pub id: ItemId,
pub name: String,
@@ -375,19 +375,19 @@ impl ItemProperties for TypeAlias {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Generic {
pub name: String,
pub numeric: Option,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TraitConstraint {
pub r#type: Type,
pub bound: TraitBound,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TraitBound {
pub trait_id: ItemId,
pub trait_name: String,
@@ -395,7 +395,7 @@ pub struct TraitBound {
pub named_generics: BTreeMap,
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum Type {
Unit,
Primitive(PrimitiveTypeKind),
@@ -449,7 +449,7 @@ pub enum Type {
},
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct PrimitiveType {
pub kind: PrimitiveTypeKind,
pub impls: Vec,
@@ -471,7 +471,7 @@ impl ItemProperties for PrimitiveType {
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Reexport {
pub id: ItemId,
pub item_name: String,
diff --git a/tooling/nargo_doc/src/lib.rs b/tooling/nargo_doc/src/lib.rs
index 095390afb75..0a4eb6c09ec 100644
--- a/tooling/nargo_doc/src/lib.rs
+++ b/tooling/nargo_doc/src/lib.rs
@@ -689,12 +689,12 @@ impl DocItemBuilder<'_> {
}
let imports = self.module_imports.remove(&module.module_id).unwrap();
+ let non_private_imports = imports
+ .into_iter()
+ .filter(|import| import.visibility != ItemVisibility::Private)
+ .collect::>();
- for import in imports {
- if import.visibility == ItemVisibility::Private {
- continue;
- }
-
+ for import in non_private_imports {
let item_id = get_module_def_id(import.id, self.interner);
if let Some(converted_item) = self.item_id_to_converted_item.get(&item_id) {
// Check if this is a re-export of a private item. The private item won't show up in
@@ -726,6 +726,11 @@ impl DocItemBuilder<'_> {
}),
));
}
+
+ // The module changed (it got new items). Because it can still be looked up in
+ // `item_id_to_converted_item` we need to update its definition there too.
+ self.item_id_to_converted_item.get_mut(&module.id).unwrap().item =
+ Item::Module(module.clone());
}
fn doc_comments(&mut self, id: ReferenceId) -> Option<(String, Links)> {