Skip to content

Commit

Permalink
Fix incremental compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Apr 28, 2020
1 parent 0a010b3 commit bd61870
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder.rs
Expand Up @@ -798,7 +798,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
)
}

fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef {
fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
let kind = self.kind(item_id);
let did = self.local_def_id(item_id);

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_middle/arena.rs
Expand Up @@ -12,8 +12,11 @@ macro_rules! arena_types {
($macro:path, $args:tt, $tcx:lifetime) => (
$macro!($args, [
[] layouts: rustc_target::abi::Layout,
// AdtDef are interned and compared by address
[] adt_def: rustc_middle::ty::AdtDef,
[decode] tables: rustc_middle::ty::TypeckTables<$tcx>,
[] const_allocs: rustc_middle::mir::interpret::Allocation,
// Required for the incremental on-disk cache
[few, decode] mir_keys: rustc_hir::def_id::DefIdSet,
[] region_scope_tree: rustc_middle::middle::region::ScopeTree,
[] dropck_outlives:
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_middle/query/mod.rs
Expand Up @@ -282,8 +282,7 @@ rustc_queries! {
query trait_def(_: DefId) -> ty::TraitDef {
storage(ArenaCacheSelector<'tcx>)
}
query adt_def(_: DefId) -> ty::AdtDef {
storage(ArenaCacheSelector<'tcx>)
query adt_def(_: DefId) -> &'tcx ty::AdtDef {
}
query adt_destructor(_: DefId) -> Option<ty::Destructor> {}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/context.rs
Expand Up @@ -1008,8 +1008,8 @@ impl<'tcx> TyCtxt<'tcx> {
kind: AdtKind,
variants: IndexVec<VariantIdx, ty::VariantDef>,
repr: ReprOptions,
) -> ty::AdtDef {
ty::AdtDef::new(self, did, kind, variants, repr)
) -> &'tcx ty::AdtDef {
self.arena.alloc(ty::AdtDef::new(self, did, kind, variants, repr))
}

pub fn intern_const_alloc(self, alloc: Allocation) -> &'tcx Allocation {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Expand Up @@ -861,7 +861,7 @@ fn convert_variant(
)
}

fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtDef {
fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AdtDef {
use rustc_hir::*;

let def_id = def_id.expect_local();
Expand Down

0 comments on commit bd61870

Please sign in to comment.