Skip to content

Commit da69bbc

Browse files
committed
also reset anon-param-mode for fn() types
1 parent 9acb351 commit da69bbc

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

src/librustc/hir/lowering.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -1033,17 +1033,22 @@ impl<'a> LoweringContext<'a> {
10331033
_ => None,
10341034
}),
10351035
|this| {
1036-
hir::TyBareFn(P(hir::BareFnTy {
1037-
generic_params: this.lower_generic_params(
1038-
&f.generic_params,
1039-
&NodeMap(),
1040-
ImplTraitContext::Disallowed,
1041-
),
1042-
unsafety: this.lower_unsafety(f.unsafety),
1043-
abi: f.abi,
1044-
decl: this.lower_fn_decl(&f.decl, None, false),
1045-
arg_names: this.lower_fn_args_to_names(&f.decl),
1046-
}))
1036+
this.with_anonymous_lifetime_mode(
1037+
AnonymousLifetimeMode::PassThrough,
1038+
|this| {
1039+
hir::TyBareFn(P(hir::BareFnTy {
1040+
generic_params: this.lower_generic_params(
1041+
&f.generic_params,
1042+
&NodeMap(),
1043+
ImplTraitContext::Disallowed,
1044+
),
1045+
unsafety: this.lower_unsafety(f.unsafety),
1046+
abi: f.abi,
1047+
decl: this.lower_fn_decl(&f.decl, None, false),
1048+
arg_names: this.lower_fn_args_to_names(&f.decl),
1049+
}))
1050+
},
1051+
)
10471052
},
10481053
),
10491054
TyKind::Never => hir::TyNever,
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for #51008 -- the anonymous lifetime in `&i32` was
12+
// being incorrectly considered part of the "elided lifetimes" from
13+
// the impl.
14+
//
15+
// run-pass
16+
17+
#![feature(rust_2018_preview)]
18+
19+
trait A {
20+
21+
}
22+
23+
impl<F> A for F where F: PartialEq<fn(&i32)> { }
24+
25+
fn main() {}

0 commit comments

Comments
 (0)