Skip to content

Commit b276429

Browse files
committed
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.
1 parent 9b4372e commit b276429

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ impl<'a> LoweringContext<'a> {
10181018
}
10191019
PathParameters::Parenthesized(ref data) => match parenthesized_generic_args {
10201020
ParenthesizedGenericArgs::Ok =>
1021-
self.lower_parenthesized_parameter_data(data, itctx),
1021+
self.lower_parenthesized_parameter_data(data),
10221022
ParenthesizedGenericArgs::Warn => {
10231023
self.sess.buffer_lint(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
10241024
CRATE_NODE_ID, data.span, msg.into());
@@ -1063,8 +1063,7 @@ impl<'a> LoweringContext<'a> {
10631063
}
10641064

10651065
fn lower_parenthesized_parameter_data(&mut self,
1066-
data: &ParenthesizedParameterData,
1067-
itctx: ImplTraitContext)
1066+
data: &ParenthesizedParameterData)
10681067
-> (hir::PathParameters, bool) {
10691068
const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed;
10701069
let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
@@ -1080,7 +1079,7 @@ impl<'a> LoweringContext<'a> {
10801079
bindings: hir_vec![hir::TypeBinding {
10811080
id: self.next_id().node_id,
10821081
name: Symbol::intern(FN_OUTPUT_NAME),
1083-
ty: output.as_ref().map(|ty| self.lower_ty(&ty, itctx))
1082+
ty: output.as_ref().map(|ty| self.lower_ty(&ty, DISALLOWED))
10841083
.unwrap_or_else(|| mk_tup(self, hir::HirVec::new(), span)),
10851084
span: output.as_ref().map_or(span, |ty| ty.span),
10861085
}],

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
#![feature(conservative_impl_trait)]
1212

13-
pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
14-
move |b| move |c| move |d| a + b + c + d
15-
}
13+
// NOTE commented out due to issue #45994
14+
//pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
15+
// move |b| move |c| move |d| a + b + c + d
16+
//}
1617

1718
fn some_internal_fn() -> u32 {
1819
1

src/test/run-pass/impl-trait/xcrate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
extern crate xcrate;
1414

1515
fn main() {
16-
assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
16+
// NOTE line below commeted out due to issue #45994
17+
// assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
1718
xcrate::return_closure_accessing_internal_fn()();
1819
}

0 commit comments

Comments
 (0)