Skip to content
Permalink
Browse files

Allow fallible `lift_to_global` in existential type writeback

  • Loading branch information...
varkor committed May 10, 2019
1 parent cff1bdb commit 26afc4fb91827a174b044ab210cbb2fef1792b5b
Showing with 26 additions and 19 deletions.
  1. +26 −19 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",
);
}
}
}

0 comments on commit 26afc4f

Please sign in to comment.
You can’t perform that action at this time.