- let mut process_alias = true;
- for tok in t.generics.params.iter() {
- if let syn::GenericParam::Lifetime(_) = tok {}
- else { process_alias = false; }
- }
- if process_alias {
- match &*t.ty {
- syn::Type::Path(_) =>
- writeln_opaque(&mut out, &t.ident, &format!("{}", t.ident), &t.generics, &t.attrs, &type_resolver, header_file, cpp_header_file),
- _ => {}
- }
+ match &*t.ty {
+ syn::Type::Path(p) => {
+ let real_ty = type_resolver.resolve_path(&p.path, None);
+ let real_generic_bounds = type_resolver.crate_types.opaques.get(&real_ty).map(|t| t.1).or(
+ type_resolver.crate_types.priv_structs.get(&real_ty).map(|r| *r)).unwrap();
+ let mut resolved_generics = t.generics.clone();
+
+ // Assume blindly that the bounds in the struct definition where
+ // clause matches any equivalent bounds on the type alias.
+ assert!(resolved_generics.where_clause.is_none());
+ resolved_generics.where_clause = real_generic_bounds.where_clause.clone();
+
+ if let syn::PathArguments::AngleBracketed(real_generics) = &p.path.segments.last().unwrap().arguments {
+ for (real_idx, real_param) in real_generics.args.iter().enumerate() {
+ if let syn::GenericArgument::Type(syn::Type::Path(real_param_path)) = real_param {
+ for param in resolved_generics.params.iter_mut() {
+ if let syn::GenericParam::Type(type_param) = param {
+ if Some(&type_param.ident) == real_param_path.path.get_ident() {
+ if let syn::GenericParam::Type(real_type_param) = &real_generic_bounds.params[real_idx] {
+ type_param.bounds = real_type_param.bounds.clone();
+ type_param.default = real_type_param.default.clone();
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ writeln_opaque(&mut out, &t.ident, &format!("{}", t.ident), &resolved_generics, &t.attrs, &type_resolver, header_file, cpp_header_file)},
+ _ => {}