diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-08 07:37:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-08 07:37:29 +0200 |
| commit | 148a44a001ccffbcf0baca5ec0a4b160f41ef99d (patch) | |
| tree | 333b0d6ac191ccfdb98567613b7139db920a5e77 /compiler/rustc_ty_utils/src | |
| parent | 47aee31b2a89cb7de97d779869a30b046632b6af (diff) | |
| parent | 8f1fff04a72f65bc991b0c76b7b7300384b0d33d (diff) | |
| download | rust-148a44a001ccffbcf0baca5ec0a4b160f41ef99d.tar.gz rust-148a44a001ccffbcf0baca5ec0a4b160f41ef99d.zip | |
Rollup merge of #97595 - ouz-a:issue-97381, r=compiler-errors
Remove unwrap from get_vtable This avoids ICE on issue #97381 I think the bug is a bit deeper though, it compiles fine when `v` is `&v` which makes me think `Deref` is causing some issue with borrowck but it's fine I guess since this thing crashes since `nightly-2020-09-17` 😅
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 17eac2bb2c9..c78a5855edb 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -347,11 +347,15 @@ fn resolve_associated_item<'tcx>( _ => None, }, traits::ImplSource::Object(ref data) => { - let index = traits::get_vtable_index_of_object_method(tcx, data, trait_item_id); - Some(Instance { - def: ty::InstanceDef::Virtual(trait_item_id, index), - substs: rcvr_substs, - }) + if let Some(index) = traits::get_vtable_index_of_object_method(tcx, data, trait_item_id) + { + Some(Instance { + def: ty::InstanceDef::Virtual(trait_item_id, index), + substs: rcvr_substs, + }) + } else { + None + } } traits::ImplSource::Builtin(..) => { if Some(trait_ref.def_id) == tcx.lang_items().clone_trait() { |
