librustc: Implement simple where clauses.
These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change]
This commit is contained in:
parent
a8c8e3f80f
commit
604af3f6c0
25 changed files with 626 additions and 207 deletions
|
|
@ -390,7 +390,7 @@ impl<'a> TraitDef<'a> {
|
|||
methods: Vec<Gc<ast::Method>> ) -> Gc<ast::Item> {
|
||||
let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
|
||||
|
||||
let Generics { mut lifetimes, ty_params } =
|
||||
let Generics { mut lifetimes, ty_params, where_clause: _ } =
|
||||
self.generics.to_generics(cx, self.span, type_ident, generics);
|
||||
let mut ty_params = ty_params.into_vec();
|
||||
|
||||
|
|
@ -418,7 +418,11 @@ impl<'a> TraitDef<'a> {
|
|||
}));
|
||||
let trait_generics = Generics {
|
||||
lifetimes: lifetimes,
|
||||
ty_params: OwnedSlice::from_vec(ty_params)
|
||||
ty_params: OwnedSlice::from_vec(ty_params),
|
||||
where_clause: ast::WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
},
|
||||
};
|
||||
|
||||
// Create the reference to the trait.
|
||||
|
|
|
|||
|
|
@ -202,10 +202,15 @@ fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str,
|
|||
cx.typaram(span, cx.ident_of(name), bounds, unbound, None)
|
||||
}
|
||||
|
||||
fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam> ) -> Generics {
|
||||
fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>)
|
||||
-> Generics {
|
||||
Generics {
|
||||
lifetimes: lifetimes,
|
||||
ty_params: OwnedSlice::from_vec(ty_params)
|
||||
ty_params: OwnedSlice::from_vec(ty_params),
|
||||
where_clause: ast::WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
predicates: Vec::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue