diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-05-04 03:14:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-04 03:14:57 +0200 |
| commit | 911bf894682b384f10a6d10c3d69491c0fdf83bc (patch) | |
| tree | cd6bd87cf1321f1d1c736b308fa29ae8d1c89c67 /src/test | |
| parent | ccc123a1e2a525c81173d432a9b53e90498a6ab3 (diff) | |
| parent | 9e19f3a27f61596a45103c815ab4fe3f38e71272 (diff) | |
Rollup merge of #71801 - matthewjasper:operator-subtyping, r=varkor
Correctly check comparison operator in MIR typeck The subtyping for comparisons between pointers was reversed in MIR typeck. There also wasn't a check that comparisons between numeric types had matching types.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/nll/type-check-pointer-comparisons.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/nll/type-check-pointer-comparisons.stderr | 14 |
2 files changed, 5 insertions, 17 deletions
diff --git a/src/test/ui/nll/type-check-pointer-comparisons.rs b/src/test/ui/nll/type-check-pointer-comparisons.rs index 298a6ef7ab3..3c900356fab 100644 --- a/src/test/ui/nll/type-check-pointer-comparisons.rs +++ b/src/test/ui/nll/type-check-pointer-comparisons.rs @@ -21,13 +21,13 @@ fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) { } fn compare_hr_fn_ptr<'a>(f: fn(&'a i32), g: fn(&i32)) { - f == g; - //~^ ERROR higher-ranked subtype error + // Ideally this should compile with the operands swapped as well, but HIR + // type checking prevents it (and stops compilation) for now. + f == g; // OK } fn compare_const_fn_ptr<'a>(f: *const fn(&'a i32), g: *const fn(&i32)) { - f == g; - //~^ ERROR higher-ranked subtype error + f == g; // OK } fn main() {} diff --git a/src/test/ui/nll/type-check-pointer-comparisons.stderr b/src/test/ui/nll/type-check-pointer-comparisons.stderr index 0fc7480260f..f350b861eb6 100644 --- a/src/test/ui/nll/type-check-pointer-comparisons.stderr +++ b/src/test/ui/nll/type-check-pointer-comparisons.stderr @@ -76,17 +76,5 @@ LL | f == g; help: `'a` and `'b` must be the same: replace one with the other -error: higher-ranked subtype error - --> $DIR/type-check-pointer-comparisons.rs:24:5 - | -LL | f == g; - | ^^^^^^ - -error: higher-ranked subtype error - --> $DIR/type-check-pointer-comparisons.rs:29:5 - | -LL | f == g; - | ^^^^^^ - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors |
