librustc: Implement unboxed closures with mutable receivers
This commit is contained in:
parent
5ddc7b4a25
commit
02adaca4dc
77 changed files with 1905 additions and 384 deletions
|
|
@ -183,6 +183,8 @@
|
|||
use std::cell::RefCell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
use abi::Abi;
|
||||
use abi;
|
||||
use ast;
|
||||
use ast::{P, EnumDef, Expr, Ident, Generics, StructDef};
|
||||
use ast_util;
|
||||
|
|
@ -477,9 +479,13 @@ impl<'a> TraitDef<'a> {
|
|||
nonself_args.as_slice())
|
||||
};
|
||||
|
||||
method_def.create_method(cx, self,
|
||||
type_ident, generics,
|
||||
explicit_self, tys,
|
||||
method_def.create_method(cx,
|
||||
self,
|
||||
type_ident,
|
||||
generics,
|
||||
abi::Rust,
|
||||
explicit_self,
|
||||
tys,
|
||||
body)
|
||||
}).collect();
|
||||
|
||||
|
|
@ -513,9 +519,13 @@ impl<'a> TraitDef<'a> {
|
|||
nonself_args.as_slice())
|
||||
};
|
||||
|
||||
method_def.create_method(cx, self,
|
||||
type_ident, generics,
|
||||
explicit_self, tys,
|
||||
method_def.create_method(cx,
|
||||
self,
|
||||
type_ident,
|
||||
generics,
|
||||
abi::Rust,
|
||||
explicit_self,
|
||||
tys,
|
||||
body)
|
||||
}).collect();
|
||||
|
||||
|
|
@ -622,9 +632,11 @@ impl<'a> MethodDef<'a> {
|
|||
trait_: &TraitDef,
|
||||
type_ident: Ident,
|
||||
generics: &Generics,
|
||||
abi: Abi,
|
||||
explicit_self: ast::ExplicitSelf,
|
||||
arg_types: Vec<(Ident, P<ast::Ty>)> ,
|
||||
body: Gc<Expr>) -> Gc<ast::Method> {
|
||||
body: Gc<Expr>)
|
||||
-> Gc<ast::Method> {
|
||||
// create the generics that aren't for Self
|
||||
let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics);
|
||||
|
||||
|
|
@ -653,6 +665,7 @@ impl<'a> MethodDef<'a> {
|
|||
span: trait_.span,
|
||||
node: ast::MethDecl(method_ident,
|
||||
fn_generics,
|
||||
abi,
|
||||
explicit_self,
|
||||
ast::NormalFn,
|
||||
fn_decl,
|
||||
|
|
|
|||
|
|
@ -910,7 +910,14 @@ impl<'a> Folder for PatIdentRenamer<'a> {
|
|||
fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast::Method>> {
|
||||
let id = fld.new_id(m.id);
|
||||
match m.node {
|
||||
ast::MethDecl(ident, ref generics, ref explicit_self, fn_style, decl, body, vis) => {
|
||||
ast::MethDecl(ident,
|
||||
ref generics,
|
||||
abi,
|
||||
ref explicit_self,
|
||||
fn_style,
|
||||
decl,
|
||||
body,
|
||||
vis) => {
|
||||
let (rewritten_fn_decl, rewritten_body)
|
||||
= expand_and_rename_fn_decl_and_block(&*decl,body,fld);
|
||||
SmallVector::one(box(GC) ast::Method {
|
||||
|
|
@ -919,6 +926,7 @@ fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast
|
|||
span: fld.new_span(m.span),
|
||||
node: ast::MethDecl(fld.fold_ident(ident),
|
||||
fold_generics(generics, fld),
|
||||
abi,
|
||||
fld.fold_explicit_self(explicit_self),
|
||||
fn_style,
|
||||
rewritten_fn_decl,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue