diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-11 01:52:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-11 01:52:29 +0200 |
| commit | 0a6d1778ffddc6767cc705385d5616fb1fffd961 (patch) | |
| tree | 028dba4bd2071a198d45022175f99446a83d5e41 /src/test/codegen/src-hash-algorithm | |
| parent | 8c097d5c38f906ec1f77685714f7b7f403f5420d (diff) | |
| parent | 75cc40335c5ca83ffa636ea6ff249d1934223b8b (diff) | |
| download | rust-0a6d1778ffddc6767cc705385d5616fb1fffd961.tar.gz rust-0a6d1778ffddc6767cc705385d5616fb1fffd961.zip | |
Rollup merge of #70982 - ldm0:fncoerce, r=eddyb
Normalize function signature in function casting check procedure
Fixes #54094
```rust
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 _;
}
```
Currently a `FnDef` need to be checked if it's able to cast to `FnPtr` before it is actually casted. But the signature of `FnPtr` target's associated types are not normalized:
https://github.com/rust-lang/rust/blob/96d77f0e5f103612d62b85938aacfb33f5768433/src/librustc_typeck/check/cast.rs#L536-L553
However, during the coercion check, the signature of `FnPtr` target's associated types are normalized (The `<u16 as Zoo>::X` turns into `usize`).
https://github.com/rust-lang/rust/blob/96d77f0e5f103612d62b85938aacfb33f5768433/src/librustc_typeck/check/coercion.rs#L687-L729
This inconsistency leads to the error:`Err(Sorts(ExpectedFound { expected: <u16 as Zoo>::X, found: usize }))`.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
