}
pub fn assert_simple_bound(bound: &syn::TraitBound) {
- if bound.paren_token.is_some() || bound.lifetimes.is_some() { unimplemented!(); }
+ if bound.paren_token.is_some() { unimplemented!(); }
if let syn::TraitBoundModifier::Maybe(_) = bound.modifier { unimplemented!(); }
}
if p.qself.is_some() { return false; }
if p.path.leading_colon.is_some() { return false; }
let mut p_iter = p.path.segments.iter();
- if let Some(gen) = new_typed_generics.get_mut(&p_iter.next().unwrap().ident) {
- if gen.is_some() { return false; }
- if &format!("{}", p_iter.next().unwrap().ident) != "Target" {return false; }
+let theident = &p_iter.next().unwrap().ident;
+eprintln!("Doing bound resolution on {}", theident);
+ if let Some(gen) = new_typed_generics.get_mut(theident) {
+ if gen.is_some() { eprintln!("5"); return false; }
+ if &format!("{}", p_iter.next().unwrap().ident) != "Target" {eprintln!("6"); return false; }
let mut non_lifetimes_processed = false;
for bound in t.bounds.iter() {
*gen = Some(types.resolve_path(&trait_bound.path, None));
}
}
- } else { return false; }
- } else { return false; }
+ } else {
+ for bound in t.bounds.iter() {
+eprintln!("XXX LULZZZZZZZZZZZZZZZZZZZZ {}", theident);
+ new_typed_generics.insert(theident, Some("lightning_invoice::payment::Router".to_string()));
+ }
+ }
+ } else { eprintln!("9"); return false; }
}
}
}
&syn::TraitItem::Type(ref t) => {
if t.default.is_some() || t.generics.lt_token.is_some() { unimplemented!(); }
let mut bounds_iter = t.bounds.iter();
- match bounds_iter.next().unwrap() {
- syn::TypeParamBound::Trait(tr) => {
- assert_simple_bound(&tr);
- if let Some(path) = types.maybe_resolve_path(&tr.path, None) {
- if types.skip_path(&path) { continue; }
- // In general we handle Deref<Target=X> as if it were just X (and
- // implement Deref<Target=Self> for relevant types). We don't
- // bother to implement it for associated types, however, so we just
- // ignore such bounds.
- if path != "std::ops::Deref" && path != "core::ops::Deref" {
- self.typed_generics.insert(&t.ident, path);
+ loop {
+ match bounds_iter.next().unwrap() {
+ syn::TypeParamBound::Trait(tr) => {
+ assert_simple_bound(&tr);
+ if let Some(path) = types.maybe_resolve_path(&tr.path, None) {
+ if types.skip_path(&path) { continue; }
+ // In general we handle Deref<Target=X> as if it were just X (and
+ // implement Deref<Target=Self> for relevant types). We don't
+ // bother to implement it for associated types, however, so we just
+ // ignore such bounds.
+ if path != "std::ops::Deref" && path != "core::ops::Deref" {
+ self.typed_generics.insert(&t.ident, path);
+ }
+ } else { unimplemented!(); }
+ for bound in bounds_iter {
+ if let syn::TypeParamBound::Trait(_) = bound { unimplemented!(); }
}
- } else { unimplemented!(); }
- },
- _ => unimplemented!(),
+ break;
+ },
+ syn::TypeParamBound::Lifetime(_) => {},
+ }
}
- if bounds_iter.next().is_some() { unimplemented!(); }
},
_ => {},
}
DeclType::MirroredEnum if is_ref && ptr_for_ref => write!(w, "crate::{}::from_native(", decl_path).unwrap(),
DeclType::MirroredEnum if is_ref => write!(w, "&crate::{}::from_native(", decl_path).unwrap(),
DeclType::MirroredEnum => write!(w, "crate::{}::native_into(", decl_path).unwrap(),
- DeclType::EnumIgnored {..}|DeclType::StructImported {..} if is_ref && ptr_for_ref && from_ptr =>
- write!(w, "crate::{} {{ inner: unsafe {{ (", decl_path).unwrap(),
+ DeclType::EnumIgnored {..}|DeclType::StructImported {..} if is_ref && from_ptr => {
+ if !ptr_for_ref { write!(w, "&").unwrap(); }
+ write!(w, "crate::{} {{ inner: unsafe {{ (", decl_path).unwrap()
+ },
DeclType::EnumIgnored {..}|DeclType::StructImported {..} if is_ref => {
if !ptr_for_ref { write!(w, "&").unwrap(); }
write!(w, "crate::{} {{ inner: unsafe {{ ObjOps::nonnull_ptr_to_inner((", decl_path).unwrap()
DeclType::EnumIgnored { generic_param_count }|DeclType::StructImported { generic_param_count } if is_ref => {
write!(w, " as *const {}<", full_path).unwrap();
for _ in 0..*generic_param_count { write!(w, "_, ").unwrap(); }
- if ptr_for_ref && from_ptr {
+ if from_ptr {
write!(w, ">) as *mut _ }}, is_owned: false }}").unwrap();
} else {
write!(w, ">) as *mut _) }}, is_owned: false }}").unwrap();