fix(codegen): Discard type defaults from impl generics

This commit is contained in:
David Tolnay
2016-04-13 23:51:04 -07:00
parent 808b06940e
commit fd3c15fb68
4 changed files with 50 additions and 3 deletions
+14
View File
@@ -7,6 +7,20 @@ use syntax::ext::base::ExtCtxt;
use syntax::ptr::P;
use syntax::visit;
// Remove the default from every type parameter because in the generated impls
// they look like associated types: "error: associated type bindings are not
// allowed here".
pub fn without_defaults(generics: &ast::Generics) -> ast::Generics {
ast::Generics {
ty_params: generics.ty_params.map(|ty_param| {
ast::TyParam {
default: None,
.. ty_param.clone()
}}),
.. generics.clone()
}
}
pub fn with_bound(
cx: &ExtCtxt,
builder: &AstBuilder,