diff options
| author | the8472 <the8472@users.noreply.github.com> | 2021-09-21 22:54:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-21 22:54:08 +0200 |
| commit | a3e6c19acf12d5995407220721f4fe28452e51da (patch) | |
| tree | 273157418d6ab67dbd8f0835a1d6b2ba4f6ce25d /compiler | |
| parent | aca790b3d62784ae6399ac2337a1147ea9aab9b8 (diff) | |
| parent | 999888c086446c4c43bd5e99d8a0d2a1a7ee0404 (diff) | |
| download | rust-a3e6c19acf12d5995407220721f4fe28452e51da.tar.gz rust-a3e6c19acf12d5995407220721f4fe28452e51da.zip | |
Rollup merge of #89147 - b-naber:refs_in_check_const_value_eq, r=oli-obk
add case for checking const refs in check_const_value_eq Previously in `check_const_value_eq` we destructured `ConstValue::ByRef` instances, this didn't account for `ty::Ref`s however, which led to an ICE. Fixes https://github.com/rust-lang/rust/issues/88876 Fixes https://github.com/rust-lang/rust/issues/88384 r? `@oli-obk`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/relate.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 9d1be212f5b..2c786538014 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -639,6 +639,15 @@ fn check_const_value_eq<R: TypeRelation<'tcx>>( get_slice_bytes(&tcx, a_val) == get_slice_bytes(&tcx, b_val) } + (ConstValue::ByRef { alloc: alloc_a, .. }, ConstValue::ByRef { alloc: alloc_b, .. }) + if a.ty.is_ref() || b.ty.is_ref() => + { + if a.ty.is_ref() && b.ty.is_ref() { + alloc_a == alloc_b + } else { + false + } + } (ConstValue::ByRef { .. }, ConstValue::ByRef { .. }) => { let a_destructured = tcx.destructure_const(relation.param_env().and(a)); let b_destructured = tcx.destructure_const(relation.param_env().and(b)); |
