Emit diagnostic on cyclic structs
diff --git a/syntax/toposort.rs b/syntax/toposort.rs
index 918d939..7c210f2 100644
--- a/syntax/toposort.rs
+++ b/syntax/toposort.rs
@@ -12,7 +12,7 @@
     let ref mut marks = Map::new();
     for api in apis {
         if let Api::Struct(strct) = api {
-            visit(cx, strct, &mut sorted, marks, types);
+            let _ = visit(cx, strct, &mut sorted, marks, types);
         }
     }
     sorted
@@ -24,11 +24,11 @@
     sorted: &mut Vec<&'a Struct>,
     marks: &mut Map<*const Struct, Mark>,
     types: &Types<'a>,
-) {
+) -> Result<(), ()> {
     match marks.entry(strct) {
         Entry::Occupied(entry) => match entry.get() {
-            Mark::Visiting => panic!("not a DAG"), // FIXME
-            Mark::Visited => return,
+            Mark::Visiting => return Err(()), // not a DAG
+            Mark::Visited => return Ok(()),
         },
         Entry::Vacant(entry) => {
             entry.insert(Mark::Visiting);
@@ -37,10 +37,13 @@
     for field in &strct.fields {
         if let Type::Ident(ident) = &field.ty {
             if let Some(inner) = types.structs.get(&ident.rust) {
-                visit(cx, inner, sorted, marks, types);
+                if visit(cx, inner, sorted, marks, types).is_err() {
+                    cx.error(field, "unsupported cyclic data structure");
+                }
             }
         }
     }
     marks.insert(strct, Mark::Visited);
     sorted.push(strct);
+    Ok(())
 }