|
11 | 11 | //! Code to save/load the dep-graph from files.
|
12 | 12 |
|
13 | 13 | use calculate_svh::SvhCalculate;
|
14 |
| -use rbml::{self, Doc}; |
15 |
| -use rbml::reader::{self, DecodeResult, Decoder}; |
| 14 | +use rbml::Error; |
| 15 | +use rbml::opaque::Decoder; |
16 | 16 | use rustc::dep_graph::DepNode;
|
17 | 17 | use rustc::middle::def_id::DefId;
|
18 | 18 | use rustc::ty;
|
@@ -66,42 +66,30 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
|
66 | 66 | }
|
67 | 67 | }
|
68 | 68 |
|
69 |
| - match decode_dep_graph(tcx, Doc::new(&data)) { |
| 69 | + match decode_dep_graph(tcx, &data) { |
70 | 70 | Ok(dirty) => dirty,
|
71 | 71 | Err(err) => {
|
72 | 72 | bug!("decoding error in dep-graph from `{}`: {}", path.display(), err);
|
73 | 73 | }
|
74 | 74 | }
|
75 | 75 | }
|
76 | 76 |
|
77 |
| -pub fn decode_dep_graph<'tcx, 'doc>(tcx: &ty::TyCtxt<'tcx>, doc: rbml::Doc<'doc>) |
78 |
| - -> DecodeResult<()> |
| 77 | +pub fn decode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>, data: &[u8]) |
| 78 | + -> Result<(), Error> |
79 | 79 | {
|
80 |
| - // First load the directory, which maps the def-ids found |
81 |
| - // elsewhere into `DefPath`. We can then refresh the `DefPath` to |
82 |
| - // obtain updated def-ids. |
83 |
| - let directory = { |
84 |
| - let directory_doc = reader::get_doc(doc, DIRECTORY_TAG); |
85 |
| - let mut decoder = Decoder::new(directory_doc); |
86 |
| - try!(DefIdDirectory::decode(&mut decoder)) |
87 |
| - }; |
| 80 | + // Deserialize the directory and dep-graph. |
| 81 | + let mut decoder = Decoder::new(data, 0); |
| 82 | + let directory = try!(DefIdDirectory::decode(&mut decoder)); |
| 83 | + let serialized_dep_graph = try!(SerializedDepGraph::decode(&mut decoder)); |
88 | 84 |
|
89 | 85 | debug!("decode_dep_graph: directory = {:#?}", directory);
|
| 86 | + debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph); |
90 | 87 |
|
91 |
| - // Retrace those paths to find their current location (if any). |
| 88 | + // Retrace the paths in the directory to find their current location (if any). |
92 | 89 | let retraced = directory.retrace(tcx);
|
93 | 90 |
|
94 | 91 | debug!("decode_dep_graph: retraced = {:#?}", retraced);
|
95 | 92 |
|
96 |
| - // Deserialize the dep-graph (which will include DefPathIndex entries) |
97 |
| - let serialized_dep_graph = { |
98 |
| - let dep_graph_doc = reader::get_doc(doc, DEP_GRAPH_TAG); |
99 |
| - let mut decoder = Decoder::new(dep_graph_doc); |
100 |
| - try!(SerializedDepGraph::decode(&mut decoder)) |
101 |
| - }; |
102 |
| - |
103 |
| - debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph); |
104 |
| - |
105 | 93 | // Compute the set of Hir nodes whose data has changed.
|
106 | 94 | let mut dirty_nodes =
|
107 | 95 | initial_dirty_nodes(tcx, &serialized_dep_graph.hashes, &retraced);
|
|
0 commit comments