Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Comment on lines 538 to +542
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nikomatsakis This makes sense to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems like it is necessary, given that fn_sig returns the result of data from the def_id ..

let res = fcx.try_coerce(
self.expr,
self.expr_ty,
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/issues/issue-54094.rs
Original file line number Diff line number Diff line change
@@ -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 _;
}