Skip to content

Commit 68b38c3

Browse files
committed
Normalize function signature in function casting check
1 parent 0c835b0 commit 68b38c3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/librustc_typeck/check/cast.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,10 @@ impl<'a, 'tcx> CastCheck<'tcx> {
536536
match self.expr_ty.kind {
537537
ty::FnDef(..) => {
538538
// Attempt a coercion to a fn pointer type.
539-
let f = self.expr_ty.fn_sig(fcx.tcx);
539+
let f = fcx.normalize_associated_types_in(
540+
self.expr.span,
541+
&self.expr_ty.fn_sig(fcx.tcx),
542+
);
540543
let res = fcx.try_coerce(
541544
self.expr,
542545
self.expr_ty,

src/test/ui/issues/issue-54094.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
trait Zoo {
3+
type X;
4+
}
5+
6+
impl Zoo for u16 {
7+
type X = usize;
8+
}
9+
10+
fn foo(abc: <u16 as Zoo>::X) {}
11+
12+
fn main() {
13+
let x: *const u8 = foo as _;
14+
}

0 commit comments

Comments
 (0)