Pass error reporting context to topological sort
diff --git a/syntax/toposort.rs b/syntax/toposort.rs
index 62a1148..918d939 100644
--- a/syntax/toposort.rs
+++ b/syntax/toposort.rs
@@ -1,3 +1,4 @@
+use crate::syntax::report::Errors;
use crate::syntax::{Api, Struct, Type, Types};
use std::collections::btree_map::{BTreeMap as Map, Entry};
@@ -6,18 +7,19 @@
Visited,
}
-pub fn sort<'a>(apis: &'a [Api], types: &Types<'a>) -> Vec<&'a Struct> {
+pub fn sort<'a>(cx: &mut Errors, apis: &'a [Api], types: &Types<'a>) -> Vec<&'a Struct> {
let mut sorted = Vec::new();
let ref mut marks = Map::new();
for api in apis {
if let Api::Struct(strct) = api {
- visit(strct, &mut sorted, marks, types);
+ visit(cx, strct, &mut sorted, marks, types);
}
}
sorted
}
fn visit<'a>(
+ cx: &mut Errors,
strct: &'a Struct,
sorted: &mut Vec<&'a Struct>,
marks: &mut Map<*const Struct, Mark>,
@@ -35,7 +37,7 @@
for field in &strct.fields {
if let Type::Ident(ident) = &field.ty {
if let Some(inner) = types.structs.get(&ident.rust) {
- visit(inner, sorted, marks, types);
+ visit(cx, inner, sorted, marks, types);
}
}
}
diff --git a/syntax/types.rs b/syntax/types.rs
index ef2e5e6..50325d6 100644
--- a/syntax/types.rs
+++ b/syntax/types.rs
@@ -211,7 +211,7 @@
toposorted_structs,
};
- types.toposorted_structs = toposort::sort(apis, &types);
+ types.toposorted_structs = toposort::sort(cx, apis, &types);
let mut unresolved_structs: Vec<&Ident> = types.structs.keys().copied().collect();
let mut new_information = true;