]> git.lizzy.rs Git - rust.git/commitdiff
Disallow all impl Trait within Fn trait sugar
authorChristopher Vittal <christopher.vittal@gmail.com>
Wed, 15 Nov 2017 00:57:09 +0000 (19:57 -0500)
committerChristopher Vittal <christopher.vittal@gmail.com>
Wed, 15 Nov 2017 20:46:01 +0000 (15:46 -0500)
We already disallowed them to be in the arg list, such as
Fn(impl Debug), but now we disallow Fn() -> impl Debug.

Also remove the ImplTraitContext argument from the function
lower_parenthesized_parameter_data as it is now unused.

Comment out part of test run-pass/impl-trait/xcrate.rs that now fails.

src/librustc/hir/lowering.rs
src/test/run-pass/impl-trait/auxiliary/xcrate.rs
src/test/run-pass/impl-trait/xcrate.rs

index e47b15e3781fbd85499dbe95778d685814250289..8c9d1a38e7088a72dc28b9a877d52351653215e6 100644 (file)
@@ -1018,7 +1018,7 @@ fn lower_path_segment(&mut self,
                 }
                 PathParameters::Parenthesized(ref data) => match parenthesized_generic_args {
                     ParenthesizedGenericArgs::Ok =>
-                        self.lower_parenthesized_parameter_data(data, itctx),
+                        self.lower_parenthesized_parameter_data(data),
                     ParenthesizedGenericArgs::Warn => {
                         self.sess.buffer_lint(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
                                               CRATE_NODE_ID, data.span, msg.into());
@@ -1063,8 +1063,7 @@ fn lower_angle_bracketed_parameter_data(&mut self,
     }
 
     fn lower_parenthesized_parameter_data(&mut self,
-                                          data: &ParenthesizedParameterData,
-                                          itctx: ImplTraitContext)
+                                          data: &ParenthesizedParameterData)
                                           -> (hir::PathParameters, bool) {
         const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed;
         let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
@@ -1080,7 +1079,7 @@ fn lower_parenthesized_parameter_data(&mut self,
             bindings: hir_vec![hir::TypeBinding {
                 id: self.next_id().node_id,
                 name: Symbol::intern(FN_OUTPUT_NAME),
-                ty: output.as_ref().map(|ty| self.lower_ty(&ty, itctx))
+                ty: output.as_ref().map(|ty| self.lower_ty(&ty, DISALLOWED))
                                    .unwrap_or_else(|| mk_tup(self, hir::HirVec::new(), span)),
                 span: output.as_ref().map_or(span, |ty| ty.span),
             }],
index e9074f8c230960efda61f3a7f0263bd35c333610..e4f525a9826100b4f20c038fd16a0e824d49f7b4 100644 (file)
 
 #![feature(conservative_impl_trait)]
 
-pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
-    move |b| move |c| move |d| a + b + c + d
-}
+// NOTE commented out due to issue #45994
+//pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
+//    move |b| move |c| move |d| a + b + c + d
+//}
 
 fn some_internal_fn() -> u32 {
     1
index 6d00c46fa35089c0a309ae8c57ec2317ba9fb31e..35ae185b3e1de285f751e32da653d6eaaab9522d 100644 (file)
@@ -13,6 +13,7 @@
 extern crate xcrate;
 
 fn main() {
-    assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
+//  NOTE line below commeted out due to issue #45994
+//  assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
     xcrate::return_closure_accessing_internal_fn()();
 }