Normalize function signature in function casting check

This commit is contained in:
Donough Liu 2020-04-10 18:14:55 +08:00
parent 0c835b0cca
commit 68b38c3bd9
2 changed files with 18 additions and 1 deletions

View File

@ -536,7 +536,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
match self.expr_ty.kind {
ty::FnDef(..) => {
// Attempt a coercion to a fn pointer type.
let f = self.expr_ty.fn_sig(fcx.tcx);
let f = fcx.normalize_associated_types_in(
self.expr.span,
&self.expr_ty.fn_sig(fcx.tcx),
);
let res = fcx.try_coerce(
self.expr,
self.expr_ty,

View File

@ -0,0 +1,14 @@
// check-pass
trait Zoo {
type X;
}
impl Zoo for u16 {
type X = usize;
}
fn foo(abc: <u16 as Zoo>::X) {}
fn main() {
let x: *const u8 = foo as _;
}