diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-08-02 16:31:39 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-08-02 16:36:09 -0400 |
| commit | 94acff180369077c64b19c1302dd48d390011ef5 (patch) | |
| tree | 81537c2de44b55b1335b5c149a92e4f68e1f4529 | |
| parent | 903142aee32b90ec945f809358eec3849e328e39 (diff) | |
| download | rust-94acff180369077c64b19c1302dd48d390011ef5.tar.gz rust-94acff180369077c64b19c1302dd48d390011ef5.zip | |
replace graph rewriting with detecting inlined ids
We now detect inlined id's earlier (in the HIR map) and rewrite a read of them to be a read of the metadata for the associated item.
| -rw-r--r-- | src/librustc/dep_graph/README.md | 25 | ||||
| -rw-r--r-- | src/librustc/dep_graph/visit.rs | 1 | ||||
| -rw-r--r-- | src/librustc/hir/map/mod.rs | 139 | ||||
| -rw-r--r-- | src/librustc/middle/cstore.rs | 12 | ||||
| -rw-r--r-- | src/librustc_const_eval/eval.rs | 4 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/hash.rs | 5 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/save.rs | 53 | ||||
| -rw-r--r-- | src/librustc_metadata/astencode.rs | 24 | ||||
| -rw-r--r-- | src/librustc_metadata/csearch.rs | 6 | ||||
| -rw-r--r-- | src/librustc_metadata/decoder.rs | 2 | ||||
| -rw-r--r-- | src/librustc_metadata/encoder.rs | 10 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 2 |
12 files changed, 154 insertions, 129 deletions
diff --git a/src/librustc/dep_graph/README.md b/src/librustc/dep_graph/README.md index ece5819829b..f16a9b386bb 100644 --- a/src/librustc/dep_graph/README.md +++ b/src/librustc/dep_graph/README.md @@ -134,6 +134,10 @@ to read from it. Similarly, reading from the `tcache` map for item `X` (which is a `DepTrackingMap`, described below) automatically invokes `dep_graph.read(ItemSignature(X))`. +**Note:** adding `Hir` nodes requires a bit of caution due to the +"inlining" that old trans and constant evaluation still use. See the +section on inlining below. + To make this strategy work, a certain amount of indirection is required. For example, modules in the HIR do not have direct pointers to the items that they contain. Rather, they contain node-ids -- one @@ -387,3 +391,24 @@ RUST_DEP_GRAPH_FILTER='Hir&foo -> TypeckItemBody & bar' This will dump out all the nodes that lead from `Hir(foo)` to `TypeckItemBody(bar)`, from which you can (hopefully) see the source of the erroneous edge. + +### Inlining of HIR nodes + +For the time being, at least, we still sometimes "inline" HIR nodes +from other crates into the current HIR map. This creates a weird +scenario where the same logical item (let's call it `X`) has two +def-ids: the original def-id `X` and a new, inlined one `X'`. `X'` is +in the current crate, but it's not like other HIR nodes: in +particular, when we restart compilation, it will not be available to +hash. Therefore, we do not want `Hir(X')` nodes appearing in our +graph. Instead, we want a "read" of `Hir(X')` to be represented as a +read of `MetaData(X)`, since the metadata for `X` is where the inlined +representation originated in the first place. + +To achieve this, the HIR map will detect if the def-id originates in +an inlined node and add a dependency to a suitable `MetaData` node +instead. If you are reading a HIR node and are not sure if it may be +inlined or not, you can use `tcx.map.read(node_id)` and it will detect +whether the node is inlined or not and do the right thing. You can +also use `tcx.map.is_inlined_def_id()` and +`tcx.map.is_inlined_node_id()` to test. diff --git a/src/librustc/dep_graph/visit.rs b/src/librustc/dep_graph/visit.rs index 5dd71db2f18..d085c24036c 100644 --- a/src/librustc/dep_graph/visit.rs +++ b/src/librustc/dep_graph/visit.rs @@ -41,6 +41,7 @@ pub fn visit_all_items_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let task_id = (self.dep_node_fn)(item_def_id); let _task = self.tcx.dep_graph.in_task(task_id.clone()); debug!("Started task {:?}", task_id); + assert!(!self.tcx.map.is_inlined_def_id(item_def_id)); self.tcx.dep_graph.read(DepNode::Hir(item_def_id)); self.visitor.visit_item(i); debug!("Ended task {:?}", task_id); diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index eea8ad9926c..86d29a6fc71 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -226,60 +226,99 @@ impl<'ast> Map<'ast> { /// otherwise have had access to those contents, and hence needs a /// read recorded). If the function just returns a DefId or /// NodeId, no actual content was returned, so no read is needed. - fn read(&self, id: NodeId) { + pub fn read(&self, id: NodeId) { self.dep_graph.read(self.dep_node(id)); } fn dep_node(&self, id0: NodeId) -> DepNode<DefId> { let map = self.map.borrow(); let mut id = id0; - loop { - match map[id as usize] { - EntryItem(_, item) => { - let def_id = self.local_def_id(item.id); - // NB ^~~~~~~ - // - // You would expect that `item.id == id`, but this - // is not always the case. In particular, for a - // ViewPath item like `use self::{mem, foo}`, we - // map the ids for `mem` and `foo` to the - // enclosing view path item. This seems mega super - // ultra wrong, but then who am I to judge? - // -nmatsakis - return DepNode::Hir(def_id); - } + if !self.is_inlined_node_id(id) { + loop { + match map[id as usize] { + EntryItem(_, item) => { + let def_id = self.local_def_id(item.id); + // NB ^~~~~~~ + // + // You would expect that `item.id == id`, but this + // is not always the case. In particular, for a + // ViewPath item like `use self::{mem, foo}`, we + // map the ids for `mem` and `foo` to the + // enclosing view path item. This seems mega super + // ultra wrong, but then who am I to judge? + // -nmatsakis + assert!(!self.is_inlined_def_id(def_id)); + return DepNode::Hir(def_id); + } - EntryForeignItem(p, _) | - EntryTraitItem(p, _) | - EntryImplItem(p, _) | - EntryVariant(p, _) | - EntryExpr(p, _) | - EntryStmt(p, _) | - EntryLocal(p, _) | - EntryPat(p, _) | - EntryBlock(p, _) | - EntryStructCtor(p, _) | - EntryLifetime(p, _) | - EntryTyParam(p, _) => - id = p, - - RootCrate | - RootInlinedParent(_) => - // FIXME(#32015) clarify story about cross-crate dep tracking - return DepNode::Krate, - - NotPresent => - // Some nodes, notably struct fields, are not - // present in the map for whatever reason, but - // they *do* have def-ids. So if we encounter an - // empty hole, check for that case. - return self.opt_local_def_id(id) - .map(|def_id| DepNode::Hir(def_id)) - .unwrap_or_else(|| { - bug!("Walking parents from `{}` \ - led to `NotPresent` at `{}`", - id0, id) - }), + EntryForeignItem(p, _) | + EntryTraitItem(p, _) | + EntryImplItem(p, _) | + EntryVariant(p, _) | + EntryExpr(p, _) | + EntryStmt(p, _) | + EntryLocal(p, _) | + EntryPat(p, _) | + EntryBlock(p, _) | + EntryStructCtor(p, _) | + EntryLifetime(p, _) | + EntryTyParam(p, _) => + id = p, + + RootCrate => + return DepNode::Krate, + + RootInlinedParent(_) => + bug!("node {} has inlined ancestor but is not inlined", id0), + + NotPresent => + // Some nodes, notably struct fields, are not + // present in the map for whatever reason, but + // they *do* have def-ids. So if we encounter an + // empty hole, check for that case. + return self.opt_local_def_id(id) + .map(|def_id| DepNode::Hir(def_id)) + .unwrap_or_else(|| { + bug!("Walking parents from `{}` \ + led to `NotPresent` at `{}`", + id0, id) + }), + } + } + } else { + // reading from an inlined def-id is really a read out of + // the metadata from which we loaded the item. + loop { + match map[id as usize] { + EntryItem(p, _) | + EntryForeignItem(p, _) | + EntryTraitItem(p, _) | + EntryImplItem(p, _) | + EntryVariant(p, _) | + EntryExpr(p, _) | + EntryStmt(p, _) | + EntryLocal(p, _) | + EntryPat(p, _) | + EntryBlock(p, _) | + EntryStructCtor(p, _) | + EntryLifetime(p, _) | + EntryTyParam(p, _) => + id = p, + + RootInlinedParent(parent) => match *parent { + InlinedItem::Item(def_id, _) | + InlinedItem::TraitItem(def_id, _) | + InlinedItem::ImplItem(def_id, _) | + InlinedItem::Foreign(def_id, _) => + return DepNode::MetaData(def_id) + }, + + RootCrate => + bug!("node {} has crate ancestor but is inlined", id0), + + NotPresent => + bug!("node {} is inlined but not present in map", id0), + } } } } @@ -876,7 +915,8 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>, -> &'ast InlinedItem { let mut fld = IdAndSpanUpdater::new(fold_ops); let ii = match ii { - II::Item(i) => II::Item(i.map(|i| fld.fold_item(i))), + II::Item(d, i) => II::Item(fld.fold_ops.new_def_id(d), + i.map(|i| fld.fold_item(i))), II::TraitItem(d, ti) => { II::TraitItem(fld.fold_ops.new_def_id(d), ti.map(|ti| fld.fold_trait_item(ti))) @@ -885,7 +925,8 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>, II::ImplItem(fld.fold_ops.new_def_id(d), ii.map(|ii| fld.fold_impl_item(ii))) } - II::Foreign(i) => II::Foreign(i.map(|i| fld.fold_foreign_item(i))) + II::Foreign(d, i) => II::Foreign(fld.fold_ops.new_def_id(d), + i.map(|i| fld.fold_foreign_item(i))) }; let ii = map.forest.inlined_items.alloc(ii); diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 32344a7b9c8..f1bb3a37e3c 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -94,19 +94,19 @@ pub enum DefLike { /// that we trans. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum InlinedItem { - Item(P<hir::Item>), + Item(DefId /* def-id in source crate */, P<hir::Item>), TraitItem(DefId /* impl id */, P<hir::TraitItem>), ImplItem(DefId /* impl id */, P<hir::ImplItem>), - Foreign(P<hir::ForeignItem>), + Foreign(DefId /* extern item */, P<hir::ForeignItem>), } /// A borrowed version of `hir::InlinedItem`. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub enum InlinedItemRef<'a> { - Item(&'a hir::Item), + Item(DefId, &'a hir::Item), TraitItem(DefId, &'a hir::TraitItem), ImplItem(DefId, &'a hir::ImplItem), - Foreign(&'a hir::ForeignItem) + Foreign(DefId, &'a hir::ForeignItem) } /// Item definitions in the currently-compiled crate would have the CrateNum @@ -283,8 +283,8 @@ impl InlinedItem { where V: Visitor<'ast> { match *self { - InlinedItem::Item(ref i) => visitor.visit_item(&i), - InlinedItem::Foreign(ref i) => visitor.visit_foreign_item(&i), + InlinedItem::Item(_, ref i) => visitor.visit_item(&i), + InlinedItem::Foreign(_, ref i) => visitor.visit_foreign_item(&i), InlinedItem::TraitItem(_, ref ti) => visitor.visit_trait_item(ti), InlinedItem::ImplItem(_, ref ii) => visitor.visit_impl_item(ii), } diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index d424b57c938..227aa7f6768 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -142,7 +142,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let mut used_substs = false; let expr_ty = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) { - Some((&InlinedItem::Item(ref item), _)) => match item.node { + Some((&InlinedItem::Item(_, ref item), _)) => match item.node { hir::ItemConst(ref ty, ref const_expr) => { Some((&**const_expr, tcx.ast_ty_to_prim_ty(ty))) }, @@ -198,7 +198,7 @@ fn inline_const_fn_from_external_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let fn_id = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) { - Some((&InlinedItem::Item(ref item), _)) => Some(item.id), + Some((&InlinedItem::Item(_, ref item), _)) => Some(item.id), Some((&InlinedItem::ImplItem(_, ref item), _)) => Some(item.id), _ => None }; diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs index 0cef5fab71a..a0827cf3bf4 100644 --- a/src/librustc_incremental/persist/hash.rs +++ b/src/librustc_incremental/persist/hash.rs @@ -70,6 +70,11 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> { def_id, self.tcx.item_path_str(def_id)); + assert!(!self.tcx.map.is_inlined_def_id(def_id), + "cannot hash HIR for inlined def-id {:?} => {:?}", + def_id, + self.tcx.item_path_str(def_id)); + // FIXME(#32753) -- should we use a distinct hash here self.tcx.calculate_item_hash(def_id) } diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 64da7ad9ceb..aa9d1f4c153 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -106,7 +106,7 @@ pub fn encode_dep_graph<'a, 'tcx>(hcx: &mut HashContext<'a, 'tcx>, encoder: &mut Encoder) -> io::Result<()> { - let (nodes, edges) = post_process_graph(hcx, query); + let (nodes, edges) = (query.nodes(), query.edges()); // Create hashes for inputs. let hashes = @@ -142,57 +142,6 @@ pub fn encode_dep_graph<'a, 'tcx>(hcx: &mut HashContext<'a, 'tcx>, Ok(()) } -pub fn post_process_graph<'a, 'tcx>(hcx: &mut HashContext<'a, 'tcx>, - query: &DepGraphQuery<DefId>) - -> (Vec<DepNode<DefId>>, Vec<(DepNode<DefId>, DepNode<DefId>)>) -{ - let tcx = hcx.tcx; - let mut cache = FnvHashMap(); - - let mut uninline_def_id = |def_id: DefId| -> Option<DefId> { - if tcx.map.is_inlined_def_id(def_id) { - Some( - cache.entry(def_id) - .or_insert_with(|| { - let def_path = tcx.def_path(def_id); - debug!("post_process_graph: uninlining def-id {:?} to yield {:?}", - def_id, def_path); - let retraced_def_id = tcx.retrace_path(&def_path).unwrap(); - debug!("post_process_graph: retraced to {:?}", retraced_def_id); - retraced_def_id - }) - .clone()) - } else { - None - } - }; - - let mut uninline_metadata = |node: &DepNode<DefId>| -> DepNode<DefId> { - match *node { - DepNode::Hir(def_id) => { - match uninline_def_id(def_id) { - Some(uninlined_def_id) => DepNode::MetaData(uninlined_def_id), - None => DepNode::Hir(def_id) - } - } - _ => node.clone() - } - }; - - let nodes = query.nodes() - .into_iter() - .map(|node| uninline_metadata(node)) - .collect(); - - let edges = query.edges() - .into_iter() - .map(|(from, to)| (uninline_metadata(from), uninline_metadata(to))) - .collect(); - - (nodes, edges) -} - - pub fn encode_metadata_hashes<'a, 'tcx>(hcx: &mut HashContext<'a, 'tcx>, builder: &mut DefIdDirectoryBuilder, query: &DepGraphQuery<DefId>, diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index c39ad414492..e5aca1d1f58 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -78,8 +78,8 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, rbml_w: &mut Encoder, ii: InlinedItemRef) { let id = match ii { - InlinedItemRef::Item(i) => i.id, - InlinedItemRef::Foreign(i) => i.id, + InlinedItemRef::Item(_, i) => i.id, + InlinedItemRef::Foreign(_, i) => i.id, InlinedItemRef::TraitItem(_, ti) => ti.id, InlinedItemRef::ImplItem(_, ii) => ii.id, }; @@ -146,8 +146,8 @@ pub fn decode_inlined_item<'a, 'tcx>(cdata: &cstore::CrateMetadata, decode_ast(ast_doc), dcx); let name = match *ii { - InlinedItem::Item(ref i) => i.name, - InlinedItem::Foreign(ref i) => i.name, + InlinedItem::Item(_, ref i) => i.name, + InlinedItem::Foreign(_, ref i) => i.name, InlinedItem::TraitItem(_, ref ti) => ti.name, InlinedItem::ImplItem(_, ref ii) => ii.name }; @@ -158,7 +158,7 @@ pub fn decode_inlined_item<'a, 'tcx>(cdata: &cstore::CrateMetadata, region::resolve_inlined_item(&tcx.sess, &tcx.region_maps, ii); decode_side_tables(dcx, ast_doc); copy_item_types(dcx, ii, orig_did); - if let InlinedItem::Item(ref i) = *ii { + if let InlinedItem::Item(_, ref i) = *ii { debug!(">>> DECODED ITEM >>>\n{}\n<<< DECODED ITEM <<<", ::rustc::hir::print::item_to_string(&i)); } @@ -348,8 +348,8 @@ fn simplify_ast(ii: InlinedItemRef) -> (InlinedItem, IdRange) { let ii = match ii { // HACK we're not dropping items. - InlinedItemRef::Item(i) => { - InlinedItem::Item(P(fold::noop_fold_item(i.clone(), &mut fld))) + InlinedItemRef::Item(d, i) => { + InlinedItem::Item(d, P(fold::noop_fold_item(i.clone(), &mut fld))) } InlinedItemRef::TraitItem(d, ti) => { InlinedItem::TraitItem(d, P(fold::noop_fold_trait_item(ti.clone(), &mut fld))) @@ -357,8 +357,8 @@ fn simplify_ast(ii: InlinedItemRef) -> (InlinedItem, IdRange) { InlinedItemRef::ImplItem(d, ii) => { InlinedItem::ImplItem(d, P(fold::noop_fold_impl_item(ii.clone(), &mut fld))) } - InlinedItemRef::Foreign(i) => { - InlinedItem::Foreign(P(fold::noop_fold_foreign_item(i.clone(), &mut fld))) + InlinedItemRef::Foreign(d, i) => { + InlinedItem::Foreign(d, P(fold::noop_fold_foreign_item(i.clone(), &mut fld))) } }; @@ -1241,15 +1241,15 @@ fn copy_item_types(dcx: &DecodeContext, ii: &InlinedItem, orig_did: DefId) { } // copy the entry for the item itself let item_node_id = match ii { - &InlinedItem::Item(ref i) => i.id, + &InlinedItem::Item(_, ref i) => i.id, &InlinedItem::TraitItem(_, ref ti) => ti.id, &InlinedItem::ImplItem(_, ref ii) => ii.id, - &InlinedItem::Foreign(ref fi) => fi.id + &InlinedItem::Foreign(_, ref fi) => fi.id }; copy_item_type(dcx, item_node_id, orig_did); // copy the entries of inner items - if let &InlinedItem::Item(ref item) = ii { + if let &InlinedItem::Item(_, ref item) = ii { match item.node { hir::ItemEnum(ref def, _) => { let orig_def = dcx.tcx.lookup_adt_def(orig_did); diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index 862245b9b78..7ee6e54a666 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -546,11 +546,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { .borrow_mut() .insert(def_id, None); } - decoder::FoundAst::Found(&InlinedItem::Item(ref item)) => { + decoder::FoundAst::Found(&InlinedItem::Item(d, ref item)) => { + assert_eq!(d, def_id); let inlined_root_node_id = find_inlined_item_root(item.id); cache_inlined_item(def_id, item.id, inlined_root_node_id); } - decoder::FoundAst::Found(&InlinedItem::Foreign(ref item)) => { + decoder::FoundAst::Found(&InlinedItem::Foreign(d, ref item)) => { + assert_eq!(d, def_id); let inlined_root_node_id = find_inlined_item_root(item.id); cache_inlined_item(def_id, item.id, inlined_root_node_id); } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index d8fd25d6277..a0f9af6830a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -797,7 +797,7 @@ pub fn maybe_get_item_ast<'a, 'tcx>(cdata: Cmd, tcx: TyCtxt<'a, 'tcx, 'tcx>, id: grandparent_def_id, ast_doc, parent_did); - if let &InlinedItem::Item(ref i) = ii { + if let &InlinedItem::Item(_, ref i) = ii { return FoundAst::FoundParent(parent_did, i); } } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 732c256a191..ffd2a3535c3 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -861,7 +861,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id); encode_name(rbml_w, item.name); encode_attributes(rbml_w, &item.attrs); - encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); + encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(def_id, item)); encode_mir(ecx, rbml_w, item.id); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); @@ -879,7 +879,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_attributes(rbml_w, &item.attrs); let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs); if needs_inline || constness == hir::Constness::Const { - encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); + encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(def_id, item)); encode_mir(ecx, rbml_w, item.id); } encode_constness(rbml_w, constness); @@ -942,7 +942,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, for v in &enum_definition.variants { encode_variant_id(rbml_w, ecx.tcx.map.local_def_id(v.node.data.id())); } - encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); + encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(def_id, item)); encode_mir(ecx, rbml_w, item.id); // Encode inherent implementations for this enumeration. @@ -989,7 +989,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, needs to know*/ encode_struct_fields(rbml_w, variant); - encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); + encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(def_id, item)); encode_mir(ecx, rbml_w, item.id); // Encode inherent implementations for this structure. @@ -1311,7 +1311,7 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_bounds_and_type_for_item(rbml_w, ecx, index, nitem.id); encode_name(rbml_w, nitem.name); if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic { - encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem)); + encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(def_id, nitem)); encode_mir(ecx, rbml_w, nitem.id); } encode_attributes(rbml_w, &nitem.attrs); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ec95afe15bd..9ed95fd5009 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1436,6 +1436,7 @@ fn type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, // NB. Since the `memoized` function enters a new task, and we // are giving this task access to the item `item`, we must // register a read. + assert!(!ccx.tcx.map.is_inlined_def_id(item_def_id)); ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); compute_type_scheme_of_item(ccx, item) }) @@ -1563,6 +1564,7 @@ fn type_scheme_of_foreign_item<'a, 'tcx>( // NB. Since the `memoized` function enters a new task, and we // are giving this task access to the item `item`, we must // register a read. + assert!(!ccx.tcx.map.is_inlined_def_id(item_def_id)); ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); compute_type_scheme_of_foreign_item(ccx, item, abi) }) |
