Auto merge of #42735 - arielb1:generic-closure-fn, r=eddyb
collector: apply param substs to closures cast to fn items Fixes #42718. r? @eddyb beta-nominating because serious ICE in newly-stabilized feature.
This commit is contained in:
commit
30322efee2
2 changed files with 11 additions and 0 deletions
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::mem;
|
||||
|
||||
const FOO: fn(u8) -> u8 = |v: u8| { v };
|
||||
|
||||
const BAR: [fn(&mut u32); 5] = [
|
||||
|
|
@ -21,6 +23,10 @@ fn func_specific() -> (fn() -> u32) {
|
|||
|| return 42
|
||||
}
|
||||
|
||||
fn generic<T>(_: T) -> fn() -> usize {
|
||||
|| mem::size_of::<T>()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Items
|
||||
assert_eq!(func_specific()(), 42);
|
||||
|
|
@ -34,4 +40,5 @@ fn main() {
|
|||
assert_eq!({ BAR[2](&mut a); a }, 3);
|
||||
assert_eq!({ BAR[3](&mut a); a }, 6);
|
||||
assert_eq!({ BAR[4](&mut a); a }, 10);
|
||||
assert_eq!(generic(0i8)(), 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue