]> git.lizzy.rs Git - rust.git/commitdiff
Use FunctionRetTy::Default rather than an explicit TyKind::Infer for lambda-building
authorvarkor <github@varkor.com>
Thu, 22 Mar 2018 15:55:57 +0000 (15:55 +0000)
committervarkor <github@varkor.com>
Thu, 22 Mar 2018 15:55:57 +0000 (15:55 +0000)
This prevents explicit `-> _` return type annotations for closures generated by `lambda`.

src/librustc_allocator/expand.rs
src/libsyntax/ext/build.rs
src/libsyntax/test.rs
src/libsyntax_ext/deriving/generic/mod.rs

index 02e704b6841856779af8b5c5696d04caa96eaf0a..ee38cca7828be0ef486d8f3555d0675ee6b26524 100644 (file)
@@ -145,7 +145,7 @@ fn allocator_fn(&self, method: &AllocatorMethod) -> P<Item> {
         let result = self.call_allocator(method.name, args);
         let (output_ty, output_expr) =
             self.ret_ty(&method.output, &mut abi_args, mk, result);
-        let kind = ItemKind::Fn(self.cx.fn_decl(abi_args, output_ty),
+        let kind = ItemKind::Fn(self.cx.fn_decl(abi_args, ast::FunctionRetTy::Ty(output_ty)),
                                 Unsafety::Unsafe,
                                 dummy_spanned(Constness::NotConst),
                                 Abi::Rust,
index 9b53553bf69d723b6d921078f60f4124180e06b3..269517e998f5b1fe7dfddc9093725555ed289bf1 100644 (file)
@@ -214,7 +214,7 @@ fn item(&self, span: Span,
 
     fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg;
     // FIXME unused self
-    fn fn_decl(&self, inputs: Vec<ast::Arg> , output: P<ast::Ty>) -> P<ast::FnDecl>;
+    fn fn_decl(&self, inputs: Vec<ast::Arg> , output: ast::FunctionRetTy) -> P<ast::FnDecl>;
 
     fn item_fn_poly(&self,
                     span: Span,
@@ -924,7 +924,7 @@ fn lambda(&self,
               -> P<ast::Expr> {
         let fn_decl = self.fn_decl(
             ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(),
-            self.ty_infer(span));
+            ast::FunctionRetTy::Default(span));
 
         // FIXME -- We are using `span` as the span of the `|...|`
         // part of the lambda, but it probably (maybe?) corresponds to
@@ -970,10 +970,10 @@ fn arg(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Arg {
     }
 
     // FIXME unused self
-    fn fn_decl(&self, inputs: Vec<ast::Arg>, output: P<ast::Ty>) -> P<ast::FnDecl> {
+    fn fn_decl(&self, inputs: Vec<ast::Arg>, output: ast::FunctionRetTy) -> P<ast::FnDecl> {
         P(ast::FnDecl {
             inputs,
-            output: ast::FunctionRetTy::Ty(output),
+            output,
             variadic: false
         })
     }
@@ -1003,7 +1003,7 @@ fn item_fn_poly(&self,
         self.item(span,
                   name,
                   Vec::new(),
-                  ast::ItemKind::Fn(self.fn_decl(inputs, output),
+                  ast::ItemKind::Fn(self.fn_decl(inputs, ast::FunctionRetTy::Ty(output)),
                               ast::Unsafety::Normal,
                               dummy_spanned(ast::Constness::NotConst),
                               Abi::Rust,
index 9edfa767d31958df8c0ff07e7850c49708c072b0..67d3adc83f2d21d25f49d87d46dc1394e5a8abcb 100644 (file)
@@ -547,7 +547,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
     // pub fn main() { ... }
     let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![]));
     let main_body = ecx.block(sp, vec![call_test_main]);
-    let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], main_ret_ty),
+    let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], ast::FunctionRetTy::Ty(main_ret_ty)),
                            ast::Unsafety::Normal,
                            dummy_spanned(ast::Constness::NotConst),
                            ::abi::Abi::Rust, ast::Generics::default(), main_body);
index 49c372b751b506d4b694807aefddaf20810a2bda..3935f1722b61525670885e978fa53a15f36b02da 100644 (file)
@@ -962,7 +962,7 @@ fn create_method(&self,
         let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident);
 
         let method_ident = cx.ident_of(self.name);
-        let fn_decl = cx.fn_decl(args, ret_type);
+        let fn_decl = cx.fn_decl(args, ast::FunctionRetTy::Ty(ret_type));
         let body_block = cx.block_expr(body);
 
         let unsafety = if self.is_unsafe {