diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-03-15 14:22:11 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-03-15 14:22:11 +0100 |
| commit | afc529dbe71622fc8fcea9389de35734788a11cd (patch) | |
| tree | 81e228897f44dda21f63249dc70714d99560c711 | |
| parent | f545a21fbe9f32b6f489b064488647997f3af70e (diff) | |
| download | rust-afc529dbe71622fc8fcea9389de35734788a11cd.tar.gz rust-afc529dbe71622fc8fcea9389de35734788a11cd.zip | |
Fix assert_assignable adt checking
| -rw-r--r-- | src/value_and_place.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 1a6a301a45b..b97d3900984 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -705,6 +705,19 @@ pub(crate) fn assert_assignable<'tcx>( } // dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed } + (&ty::Adt(adt_def_a, substs_a), &ty::Adt(adt_def_b, substs_b)) + if adt_def_a.did == adt_def_b.did => + { + let mut types_a = substs_a.types(); + let mut types_b = substs_b.types(); + loop { + match (types_a.next(), types_b.next()) { + (Some(a), Some(b)) => assert_assignable(fx, a, b), + (None, None) => return, + (Some(_), None) | (None, Some(_)) => panic!("{:#?}/{:#?}", from_ty, to_ty), + } + } + } _ => { assert_eq!( from_ty, to_ty, |
