|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -use rustc::hir::intravisit::{Visitor, NestedVisitorMap}; |
12 |
| - |
13 | 11 | use isolated_encoder::IsolatedEncoder;
|
14 | 12 | use schema::*;
|
15 | 13 |
|
16 | 14 | use rustc::hir;
|
17 |
| -use rustc::ty::{self, TyCtxt}; |
18 |
| - |
19 |
| -use rustc::ich::Fingerprint; |
20 |
| -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 15 | +use rustc::ty; |
21 | 16 |
|
22 | 17 | #[derive(RustcEncodable, RustcDecodable)]
|
23 | 18 | pub struct Ast<'tcx> {
|
24 |
| - pub body: Lazy<hir::Body>, |
25 | 19 | pub tables: Lazy<ty::TypeckTables<'tcx>>,
|
26 |
| - pub nested_bodies: LazySeq<hir::Body>, |
27 | 20 | pub rvalue_promotable_to_static: bool,
|
28 |
| - pub stable_bodies_hash: Fingerprint, |
29 | 21 | }
|
30 | 22 |
|
31 | 23 | impl_stable_hash_for!(struct Ast<'tcx> {
|
32 |
| - body, |
33 | 24 | tables,
|
34 |
| - nested_bodies, |
35 |
| - rvalue_promotable_to_static, |
36 |
| - stable_bodies_hash |
| 25 | + rvalue_promotable_to_static |
37 | 26 | });
|
38 | 27 |
|
39 | 28 | impl<'a, 'b, 'tcx> IsolatedEncoder<'a, 'b, 'tcx> {
|
40 | 29 | pub fn encode_body(&mut self, body_id: hir::BodyId) -> Lazy<Ast<'tcx>> {
|
41 |
| - let body = self.tcx.hir.body(body_id); |
42 |
| - |
43 |
| - // In order to avoid having to hash hir::Bodies from extern crates, we |
44 |
| - // hash them here, during export, and store the hash with metadata. |
45 |
| - let stable_bodies_hash = { |
46 |
| - let mut hcx = self.tcx.create_stable_hashing_context(); |
47 |
| - let mut hasher = StableHasher::new(); |
48 |
| - |
49 |
| - hcx.while_hashing_hir_bodies(true, |hcx| { |
50 |
| - body.hash_stable(hcx, &mut hasher); |
51 |
| - }); |
52 |
| - |
53 |
| - hasher.finish() |
54 |
| - }; |
55 |
| - |
56 |
| - let lazy_body = self.lazy(body); |
57 | 30 | let body_owner_def_id = self.tcx.hir.body_owner_def_id(body_id);
|
58 | 31 | let tables = self.tcx.typeck_tables_of(body_owner_def_id);
|
59 | 32 | let lazy_tables = self.lazy(tables);
|
60 | 33 |
|
61 |
| - let mut visitor = NestedBodyCollector { |
62 |
| - tcx: self.tcx, |
63 |
| - bodies_found: Vec::new(), |
64 |
| - }; |
65 |
| - visitor.visit_body(body); |
66 |
| - let lazy_nested_bodies = self.lazy_seq_ref_from_slice(&visitor.bodies_found); |
67 |
| - |
68 | 34 | let rvalue_promotable_to_static =
|
69 | 35 | self.tcx.const_is_rvalue_promotable_to_static(body_owner_def_id);
|
70 | 36 |
|
71 | 37 | self.lazy(&Ast {
|
72 |
| - body: lazy_body, |
73 | 38 | tables: lazy_tables,
|
74 |
| - nested_bodies: lazy_nested_bodies, |
75 | 39 | rvalue_promotable_to_static,
|
76 |
| - stable_bodies_hash, |
77 | 40 | })
|
78 | 41 | }
|
79 | 42 | }
|
80 |
| - |
81 |
| -struct NestedBodyCollector<'a, 'tcx: 'a> { |
82 |
| - tcx: TyCtxt<'a, 'tcx, 'tcx>, |
83 |
| - bodies_found: Vec<&'tcx hir::Body>, |
84 |
| -} |
85 |
| - |
86 |
| -impl<'a, 'tcx: 'a> Visitor<'tcx> for NestedBodyCollector<'a, 'tcx> { |
87 |
| - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { |
88 |
| - NestedVisitorMap::None |
89 |
| - } |
90 |
| - |
91 |
| - fn visit_nested_body(&mut self, body: hir::BodyId) { |
92 |
| - let body = self.tcx.hir.body(body); |
93 |
| - self.bodies_found.push(body); |
94 |
| - self.visit_body(body); |
95 |
| - } |
96 |
| -} |
0 commit comments