Add support for equality constraints on associated types
This commit is contained in:
parent
da83ad8e2c
commit
397dda8aa0
29 changed files with 791 additions and 164 deletions
|
|
@ -37,7 +37,8 @@ pub trait AstBuilder {
|
|||
global: bool,
|
||||
idents: Vec<ast::Ident> ,
|
||||
lifetimes: Vec<ast::Lifetime>,
|
||||
types: Vec<P<ast::Ty>> )
|
||||
types: Vec<P<ast::Ty>>,
|
||||
bindings: Vec<P<ast::TypeBinding>> )
|
||||
-> ast::Path;
|
||||
|
||||
// types
|
||||
|
|
@ -293,20 +294,21 @@ pub trait AstBuilder {
|
|||
|
||||
impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
fn path(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path {
|
||||
self.path_all(span, false, strs, Vec::new(), Vec::new())
|
||||
self.path_all(span, false, strs, Vec::new(), Vec::new(), Vec::new())
|
||||
}
|
||||
fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path {
|
||||
self.path(span, vec!(id))
|
||||
}
|
||||
fn path_global(&self, span: Span, strs: Vec<ast::Ident> ) -> ast::Path {
|
||||
self.path_all(span, true, strs, Vec::new(), Vec::new())
|
||||
self.path_all(span, true, strs, Vec::new(), Vec::new(), Vec::new())
|
||||
}
|
||||
fn path_all(&self,
|
||||
sp: Span,
|
||||
global: bool,
|
||||
mut idents: Vec<ast::Ident> ,
|
||||
lifetimes: Vec<ast::Lifetime>,
|
||||
types: Vec<P<ast::Ty>> )
|
||||
types: Vec<P<ast::Ty>>,
|
||||
bindings: Vec<P<ast::TypeBinding>> )
|
||||
-> ast::Path {
|
||||
let last_identifier = idents.pop().unwrap();
|
||||
let mut segments: Vec<ast::PathSegment> = idents.into_iter()
|
||||
|
|
@ -321,6 +323,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData {
|
||||
lifetimes: lifetimes,
|
||||
types: OwnedSlice::from_vec(types),
|
||||
bindings: OwnedSlice::from_vec(bindings),
|
||||
})
|
||||
});
|
||||
ast::Path {
|
||||
|
|
@ -391,7 +394,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
self.ident_of("Option")
|
||||
),
|
||||
Vec::new(),
|
||||
vec!( ty )))
|
||||
vec!( ty ),
|
||||
Vec::new()))
|
||||
}
|
||||
|
||||
fn ty_field_imm(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::TypeField {
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ impl<'a> TraitDef<'a> {
|
|||
// Create the type of `self`.
|
||||
let self_type = cx.ty_path(
|
||||
cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes,
|
||||
self_ty_params.into_vec()));
|
||||
self_ty_params.into_vec(), Vec::new()));
|
||||
|
||||
let attr = cx.attribute(
|
||||
self.span,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ impl<'a> Path<'a> {
|
|||
let lt = mk_lifetimes(cx, span, &self.lifetime);
|
||||
let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
|
||||
|
||||
cx.path_all(span, self.global, idents, lt, tys)
|
||||
cx.path_all(span, self.global, idents, lt, tys, Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ impl<'a> Ty<'a> {
|
|||
.collect();
|
||||
|
||||
cx.path_all(span, false, vec!(self_ty), lifetimes,
|
||||
self_params.into_vec())
|
||||
self_params.into_vec(), Vec::new())
|
||||
}
|
||||
Literal(ref p) => {
|
||||
p.to_path(cx, span, self_ty, self_generics)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
true,
|
||||
rand_ident.clone(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Vec::new());
|
||||
let rand_name = cx.expr_path(rand_name);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
|
|||
Some(cx.lifetime(sp,
|
||||
cx.ident_of(
|
||||
"'static").name)),
|
||||
ast::MutImmutable))))
|
||||
ast::MutImmutable)),
|
||||
Vec::new()))
|
||||
}
|
||||
Some(s) => {
|
||||
cx.expr_call_global(sp,
|
||||
|
|
|
|||
|
|
@ -530,6 +530,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
self.fmtsp,
|
||||
true, Context::rtpath(self.ecx, "Argument"),
|
||||
vec![static_lifetime],
|
||||
vec![],
|
||||
vec![]
|
||||
));
|
||||
lets.push(Context::item_static_array(self.ecx,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue