Skip to content

Commit

Permalink
rustc_metadata: don't encode an empty slice for inferred_outlives.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 3, 2019
1 parent cd7cbaa commit d594fc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/librustc_metadata/decoder.rs
Expand Up @@ -671,7 +671,9 @@ impl<'a, 'tcx> CrateMetadata {
item_id: DefIndex,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
self.root.per_def.inferred_outlives.get(self, item_id).unwrap().decode((self, tcx))
self.root.per_def.inferred_outlives.get(self, item_id).map(|predicates| {
predicates.decode((self, tcx))
}).unwrap_or_default()
}

crate fn get_super_predicates(
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_metadata/encoder.rs
Expand Up @@ -842,8 +842,10 @@ impl EncodeContext<'tcx> {

fn encode_inferred_outlives(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_inferred_outlives({:?})", def_id);
record!(self.per_def.inferred_outlives[def_id] <-
self.tcx.inferred_outlives_of(def_id));
let inferred_outlives = self.tcx.inferred_outlives_of(def_id);
if !inferred_outlives.is_empty() {
record!(self.per_def.inferred_outlives[def_id] <- inferred_outlives);
}
}

fn encode_super_predicates(&mut self, def_id: DefId) {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_metadata/schema.rs
Expand Up @@ -249,6 +249,7 @@ crate struct LazyPerDefTables<'tcx> {
// doesn't handle shorthands in its own (de)serialization impls,
// as it's an `enum` for which we want to derive (de)serialization,
// so the `ty::codec` APIs handle the whole `&'tcx [...]` at once.
// Also, as an optimization, a missing entry indicates an empty `&[]`.
pub inferred_outlives: Lazy!(PerDefTable<Lazy!(&'tcx [(ty::Predicate<'tcx>, Span)])>),
pub super_predicates: Lazy!(PerDefTable<Lazy!(ty::GenericPredicates<'tcx>)>),

Expand Down

0 comments on commit d594fc2

Please sign in to comment.