diff options
| author | varkor <github@varkor.com> | 2019-05-10 22:06:03 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-05-10 22:06:03 +0100 |
| commit | 26afc4fb91827a174b044ab210cbb2fef1792b5b (patch) | |
| tree | 6a007da0f87a2c50ff8be05345aa7dd4d1051882 /src | |
| parent | cff1bdbd77d29a28a94ff9f5bf1e1c84e5bb6259 (diff) | |
| download | rust-26afc4fb91827a174b044ab210cbb2fef1792b5b.tar.gz rust-26afc4fb91827a174b044ab210cbb2fef1792b5b.zip | |
Allow fallible `lift_to_global` in existential type writeback
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/writeback.rs | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index f9d83146e30..bf978352fae 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -611,26 +611,33 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } } - let new = ty::ResolvedOpaqueTy { - concrete_type: definition_ty, - substs: self.tcx().lift_to_global(&opaque_defn.substs).unwrap(), - }; - - let old = self.tables - .concrete_existential_types - .insert(def_id, new); - if let Some(old) = old { - if old.concrete_type != definition_ty || old.substs != opaque_defn.substs { - span_bug!( - span, - "visit_opaque_types tried to write \ - different types for the same existential type: {:?}, {:?}, {:?}, {:?}", - def_id, - definition_ty, - opaque_defn, - old, - ); + if let Some(substs) = self.tcx().lift_to_global(&opaque_defn.substs) { + let new = ty::ResolvedOpaqueTy { + concrete_type: definition_ty, + substs, + }; + + let old = self.tables + .concrete_existential_types + .insert(def_id, new); + if let Some(old) = old { + if old.concrete_type != definition_ty || old.substs != opaque_defn.substs { + span_bug!( + span, + "visit_opaque_types tried to write \ + different types for the same existential type: {:?}, {:?}, {:?}, {:?}", + def_id, + definition_ty, + opaque_defn, + old, + ); + } } + } else { + self.tcx().sess.delay_span_bug( + span, + "cannot lift `opaque_defn` substs to global type context", + ); } } } |
