writeln_docs(w, &t.attrs, "");
let mut gen_types = GenericTypes::new(None);
+
+ // Add functions which may be required for supertrait implementations.
+ // Due to borrow checker limitations, we only support one in-crate supertrait here.
+ let supertrait_name;
+ let supertrait_resolver;
+ walk_supertraits!(t, Some(&types), (
+ (s, _i) => {
+ if let Some(supertrait) = types.crate_types.traits.get(s) {
+ supertrait_name = s.to_string();
+ supertrait_resolver = get_module_type_resolver!(supertrait_name, types.crate_libs, types.crate_types);
+ gen_types.learn_associated_types(&supertrait, &supertrait_resolver);
+ break;
+ }
+ }
+ ) );
+
assert!(gen_types.learn_generics(&t.generics, types));
gen_types.learn_associated_types(&t, types);
if types.understood_c_path(&trait_path.1) {
let full_trait_path = types.resolve_path(&trait_path.1, None);
let trait_obj = *types.crate_types.traits.get(&full_trait_path).unwrap();
+
+ let supertrait_name;
+ let supertrait_resolver;
+ walk_supertraits!(trait_obj, Some(&types), (
+ (s, _i) => {
+ if let Some(supertrait) = types.crate_types.traits.get(s) {
+ supertrait_name = s.to_string();
+ supertrait_resolver = get_module_type_resolver!(supertrait_name, types.crate_libs, types.crate_types);
+ gen_types.learn_associated_types(&supertrait, &supertrait_resolver);
+ break;
+ }
+ }
+ ) );
// We learn the associated types maping from the original trait object.
// That's great, except that they are unresolved idents, so if we learn
// mappings from a trai defined in a different file, we may mis-resolve or
- // fail to resolve the mapped types.
- gen_types.learn_associated_types(trait_obj, types);
+ // fail to resolve the mapped types. Thus, we have to construct a new
+ // resolver for the module that the trait was defined in here first.
+ let trait_resolver = get_module_type_resolver!(full_trait_path, types.crate_libs, types.crate_types);
+ gen_types.learn_associated_types(trait_obj, &trait_resolver);
let mut impl_associated_types = HashMap::new();
for item in i.items.iter() {
match item {