-
- // Blindly assume that the same imports where `supertrait` is defined are also
- // imported here. This will almost certainly break at some point, but it should be
- // a compilation failure when it does so.
- write!(w, "impl").unwrap();
- maybe_write_lifetime_generics(w, &supertrait.generics, types);
- write!(w, " {}", s).unwrap();
- maybe_write_generics(w, &supertrait.generics, generic_args, types, false);
- writeln!(w, " for {} {{", trait_name).unwrap();
-
- impl_trait_for_c!(supertrait, format!(".{}", i), &resolver, generic_args);
- writeln!(w, "}}").unwrap();
+ macro_rules! impl_supertrait {
+ ($s: expr, $supertrait: expr, $i: expr, $generic_args: expr) => {
+ let resolver = get_module_type_resolver!($s, types.crate_libs, types.crate_types);
+
+ // Blindly assume that the same imports where `supertrait` is defined are also
+ // imported here. This will almost certainly break at some point, but it should be
+ // a compilation failure when it does so.
+ write!(w, "impl").unwrap();
+ maybe_write_lifetime_generics(w, &$supertrait.generics, types);
+ write!(w, " {}", $s).unwrap();
+ maybe_write_generics(w, &$supertrait.generics, $generic_args, types, false);
+ writeln!(w, " for {} {{", trait_name).unwrap();
+
+ impl_trait_for_c!($supertrait, format!(".{}", $i), &resolver, $generic_args);
+ writeln!(w, "}}").unwrap();
+ }
+ }
+ impl_supertrait!(s, supertrait, i, generic_args);
+ walk_supertraits!(supertrait, Some(&resolver), (
+ (s, supertrait_i, generic_args) => {
+ if let Some(supertrait) = types.crate_types.traits.get(s) {
+ impl_supertrait!(s, supertrait, format!("{}.{}", i, supertrait_i), generic_args);
+ }
+ }
+ ) );