mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Normalize closure signature after construction
This commit is contained in:
parent
fa521a4691
commit
2db0492e62
@ -624,6 +624,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
),
|
||||
bound_vars,
|
||||
);
|
||||
// Astconv can't normalize inputs or outputs with escaping bound vars,
|
||||
// so normalize them here, after we've wrapped them in a binder.
|
||||
let result = self.normalize_associated_types_in(self.tcx.hir().span(hir_id), result);
|
||||
|
||||
let c_result = self.inh.infcx.canonicalize_response(result);
|
||||
self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);
|
||||
|
36
src/test/ui/closures/issue-101696.rs
Normal file
36
src/test/ui/closures/issue-101696.rs
Normal file
@ -0,0 +1,36 @@
|
||||
// check-pass
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Default)]
|
||||
struct MyType<'a> {
|
||||
field: usize,
|
||||
_phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MyTypeVariant<'a> {
|
||||
field: usize,
|
||||
_phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
trait AsVariantTrait {
|
||||
type Type;
|
||||
}
|
||||
|
||||
impl<'a> AsVariantTrait for MyType<'a> {
|
||||
type Type = MyTypeVariant<'a>;
|
||||
}
|
||||
|
||||
type Variant<G> = <G as AsVariantTrait>::Type;
|
||||
|
||||
fn foo<T: Default, F: FnOnce(T)>(f: F) {
|
||||
let input = T::default();
|
||||
f(input);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo(|a: <MyType as AsVariantTrait>::Type| {
|
||||
a.field;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user