diff options
| author | Donough Liu <ldm2993593805@163.com> | 2020-04-10 18:14:55 +0800 |
|---|---|---|
| committer | Donough Liu <ldm2993593805@163.com> | 2020-04-10 18:14:55 +0800 |
| commit | 68b38c3bd902deccd31d59f45d5b49e58aa76a9d (patch) | |
| tree | 83402e40ad283966e11a0729ee232afdb24ea940 | |
| parent | 0c835b0cca83fe21090562603e4bda77c183ace3 (diff) | |
| download | rust-68b38c3bd902deccd31d59f45d5b49e58aa76a9d.tar.gz rust-68b38c3bd902deccd31d59f45d5b49e58aa76a9d.zip | |
Normalize function signature in function casting check
| -rw-r--r-- | src/librustc_typeck/check/cast.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-54094.rs | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 5de0184f2bb..38d0c42e158 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -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, diff --git a/src/test/ui/issues/issue-54094.rs b/src/test/ui/issues/issue-54094.rs new file mode 100644 index 00000000000..57384825a35 --- /dev/null +++ b/src/test/ui/issues/issue-54094.rs @@ -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 _; +} \ No newline at end of file |
