Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/printer/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 21 additions & 21 deletions tooling/nargo_doc/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub type Links = Vec<Link>;

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.
Expand All @@ -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<String>,
Expand All @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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<Generic>,
pub r#type: Type,
pub methods: Vec<Function>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TraitImpl {
pub generics: Vec<Generic>,
pub trait_id: ItemId,
Expand All @@ -252,7 +252,7 @@ pub struct TraitImpl {
pub methods: Vec<Function>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Global {
pub id: ItemId,
pub name: String,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -326,13 +326,13 @@ pub struct Trait {
pub comments: Option<Comments>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct AssociatedType {
pub name: String,
pub bounds: Vec<TraitBound>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct AssociatedConstant {
pub name: String,
pub r#type: Type,
Expand All @@ -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,
Expand All @@ -375,27 +375,27 @@ impl ItemProperties for TypeAlias {
}
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Generic {
pub name: String,
pub numeric: Option<Type>,
}

#[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,
pub ordered_generics: Vec<Type>,
pub named_generics: BTreeMap<String, Type>,
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum Type {
Unit,
Primitive(PrimitiveTypeKind),
Expand Down Expand Up @@ -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<Impl>,
Expand All @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions tooling/nargo_doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

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
Expand Down Expand Up @@ -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)> {
Expand Down