Skip to content

Commit

Permalink
Allow fallible lift_to_global in existential type writeback
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed May 10, 2019
1 parent cff1bdb commit 26afc4f
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
}
}
}
Expand Down

0 comments on commit 26afc4f

Please sign in to comment.