@@ -194,10 +194,14 @@ pub trait AstBuilder {
194
194
cond: P<ast::Expr>, then: P<ast::Expr>, els: Option<P<ast::Expr>>) -> P<ast::Expr>;
195
195
fn expr_loop(&self, span: Span, block: P<ast::Block>) -> P<ast::Expr>;
196
196
197
- fn lambda_fn_decl(&self, span: Span,
198
- fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr>;
197
+ fn lambda_fn_decl(&self,
198
+ span: Span,
199
+ fn_decl: P<ast::FnDecl>,
200
+ blk: P<ast::Block>,
201
+ fn_decl_span: Span)
202
+ -> P<ast::Expr>;
199
203
200
- fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> P<ast::Expr>;
204
+ fn lambda(&self, span: Span, ids: Vec<ast::Ident>, blk: P<ast::Block>) -> P<ast::Expr>;
201
205
fn lambda0(&self, span: Span, blk: P<ast::Block>) -> P<ast::Expr>;
202
206
fn lambda1(&self, span: Span, blk: P<ast::Block>, ident: ast::Ident) -> P<ast::Expr>;
203
207
@@ -894,17 +898,34 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
894
898
self.expr(span, ast::ExprKind::Loop(block, None))
895
899
}
896
900
897
- fn lambda_fn_decl(&self, span: Span,
898
- fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr> {
899
- self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk))
901
+ fn lambda_fn_decl(&self,
902
+ span: Span,
903
+ fn_decl: P<ast::FnDecl>,
904
+ blk: P<ast::Block>,
905
+ fn_decl_span: Span) // span of the `|...|` part
906
+ -> P<ast::Expr> {
907
+ self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref,
908
+ fn_decl,
909
+ blk,
910
+ fn_decl_span))
900
911
}
901
- fn lambda(&self, span: Span, ids: Vec<ast::Ident>, blk: P<ast::Block>) -> P<ast::Expr> {
912
+
913
+ fn lambda(&self,
914
+ span: Span,
915
+ ids: Vec<ast::Ident>,
916
+ blk: P<ast::Block>)
917
+ -> P<ast::Expr> {
902
918
let fn_decl = self.fn_decl(
903
919
ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(),
904
920
self.ty_infer(span));
905
921
906
- self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk))
922
+ // FIXME -- We are using `span` as the span of the `|...|`
923
+ // part of the lambda, but it probably (maybe?) corresponds to
924
+ // the entire lambda body. Probably we should extend the API
925
+ // here, but that's not entirely clear.
926
+ self.expr(span, ast::ExprKind::Closure(ast::CaptureBy::Ref, fn_decl, blk, span))
907
927
}
928
+
908
929
fn lambda0(&self, span: Span, blk: P<ast::Block>) -> P<ast::Expr> {
909
930
self.lambda(span, Vec::new(), blk)
910
931
}
0 commit comments