@@ -36,6 +36,7 @@ use std::ops::{Index, IndexMut};
36
36
use std:: rc:: Rc ;
37
37
use std:: vec:: IntoIter ;
38
38
use syntax:: ast:: { self , Name } ;
39
+ use syntax:: symbol:: InternedString ;
39
40
use syntax_pos:: Span ;
40
41
41
42
mod cache;
@@ -75,7 +76,7 @@ pub struct Mir<'tcx> {
75
76
76
77
/// Crate-local information for each visibility scope, that can't (and
77
78
/// needn't) be tracked across crates.
78
- pub visibility_scope_info : ClearOnDecode < IndexVec < VisibilityScope , VisibilityScopeInfo > > ,
79
+ pub visibility_scope_info : ClearCrossCrate < IndexVec < VisibilityScope , VisibilityScopeInfo > > ,
79
80
80
81
/// Rvalues promoted from this function, such as borrows of constants.
81
82
/// Each of them is the Mir of a constant with the fn's type parameters
@@ -129,8 +130,8 @@ pub const START_BLOCK: BasicBlock = BasicBlock(0);
129
130
impl < ' tcx > Mir < ' tcx > {
130
131
pub fn new ( basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
131
132
visibility_scopes : IndexVec < VisibilityScope , VisibilityScopeData > ,
132
- visibility_scope_info : ClearOnDecode < IndexVec < VisibilityScope ,
133
- VisibilityScopeInfo > > ,
133
+ visibility_scope_info : ClearCrossCrate < IndexVec < VisibilityScope ,
134
+ VisibilityScopeInfo > > ,
134
135
promoted : IndexVec < Promoted , Mir < ' tcx > > ,
135
136
yield_ty : Option < Ty < ' tcx > > ,
136
137
local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
@@ -283,15 +284,15 @@ impl<'tcx> Mir<'tcx> {
283
284
}
284
285
}
285
286
286
- #[ derive( Clone , Debug ) ]
287
+ #[ derive( Clone , Debug , RustcEncodable , RustcDecodable ) ]
287
288
pub struct VisibilityScopeInfo {
288
289
/// A NodeId with lint levels equivalent to this scope's lint levels.
289
290
pub lint_root : ast:: NodeId ,
290
291
/// The unsafe block that contains this node.
291
292
pub safety : Safety ,
292
293
}
293
294
294
- #[ derive( Copy , Clone , Debug ) ]
295
+ #[ derive( Copy , Clone , Debug , RustcEncodable , RustcDecodable ) ]
295
296
pub enum Safety {
296
297
Safe ,
297
298
/// Unsafe because of a PushUnsafeBlock
@@ -335,22 +336,13 @@ impl<'tcx> IndexMut<BasicBlock> for Mir<'tcx> {
335
336
}
336
337
337
338
#[ derive( Clone , Debug ) ]
338
- pub enum ClearOnDecode < T > {
339
+ pub enum ClearCrossCrate < T > {
339
340
Clear ,
340
341
Set ( T )
341
342
}
342
343
343
- impl < T > serialize:: Encodable for ClearOnDecode < T > {
344
- fn encode < S : serialize:: Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
345
- serialize:: Encodable :: encode ( & ( ) , s)
346
- }
347
- }
348
-
349
- impl < T > serialize:: Decodable for ClearOnDecode < T > {
350
- fn decode < D : serialize:: Decoder > ( d : & mut D ) -> Result < Self , D :: Error > {
351
- serialize:: Decodable :: decode ( d) . map ( |( ) | ClearOnDecode :: Clear )
352
- }
353
- }
344
+ impl < T : serialize:: Encodable > serialize:: UseSpecializedEncodable for ClearCrossCrate < T > { }
345
+ impl < T : serialize:: Decodable > serialize:: UseSpecializedDecodable for ClearCrossCrate < T > { }
354
346
355
347
/// Grouped information about the source code origin of a MIR entity.
356
348
/// Intended to be inspected by diagnostics and debuginfo.
@@ -1733,21 +1725,21 @@ impl Location {
1733
1725
}
1734
1726
}
1735
1727
1736
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
1728
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
1737
1729
pub enum UnsafetyViolationKind {
1738
1730
General ,
1739
1731
ExternStatic ( ast:: NodeId ) ,
1740
1732
BorrowPacked ( ast:: NodeId ) ,
1741
1733
}
1742
1734
1743
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
1735
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
1744
1736
pub struct UnsafetyViolation {
1745
1737
pub source_info : SourceInfo ,
1746
- pub description : & ' static str ,
1738
+ pub description : InternedString ,
1747
1739
pub kind : UnsafetyViolationKind ,
1748
1740
}
1749
1741
1750
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
1742
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
1751
1743
pub struct UnsafetyCheckResult {
1752
1744
/// Violations that are propagated *upwards* from this function
1753
1745
pub violations : Rc < [ UnsafetyViolation ] > ,
0 commit comments