Disallow all impl Trait within Fn trait sugar

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.
This commit is contained in:
Christopher Vittal 2017-11-14 19:57:09 -05:00
parent 9b4372e3b1
commit b276429734
3 changed files with 9 additions and 8 deletions

View file

@ -1018,7 +1018,7 @@ impl<'a> LoweringContext<'a> {
}
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 @@ impl<'a> LoweringContext<'a> {
}
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 @@ impl<'a> LoweringContext<'a> {
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),
}],

View file

@ -10,9 +10,10 @@
#![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

View 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()();
}