@@ -36,6 +36,7 @@ use std::ops::{Index, IndexMut};
3636use std:: rc:: Rc ;
3737use std:: vec:: IntoIter ;
3838use syntax:: ast:: { self , Name } ;
39+ use syntax:: symbol:: InternedString ;
3940use syntax_pos:: Span ;
4041
4142mod cache;
@@ -75,7 +76,7 @@ pub struct Mir<'tcx> {
7576
7677 /// Crate-local information for each visibility scope, that can't (and
7778 /// needn't) be tracked across crates.
78- pub visibility_scope_info : ClearOnDecode < IndexVec < VisibilityScope , VisibilityScopeInfo > > ,
79+ pub visibility_scope_info : ClearCrossCrate < IndexVec < VisibilityScope , VisibilityScopeInfo > > ,
7980
8081 /// Rvalues promoted from this function, such as borrows of constants.
8182 /// 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);
129130impl < ' tcx > Mir < ' tcx > {
130131 pub fn new ( basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
131132 visibility_scopes : IndexVec < VisibilityScope , VisibilityScopeData > ,
132- visibility_scope_info : ClearOnDecode < IndexVec < VisibilityScope ,
133- VisibilityScopeInfo > > ,
133+ visibility_scope_info : ClearCrossCrate < IndexVec < VisibilityScope ,
134+ VisibilityScopeInfo > > ,
134135 promoted : IndexVec < Promoted , Mir < ' tcx > > ,
135136 yield_ty : Option < Ty < ' tcx > > ,
136137 local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
@@ -283,15 +284,15 @@ impl<'tcx> Mir<'tcx> {
283284 }
284285}
285286
286- #[ derive( Clone , Debug ) ]
287+ #[ derive( Clone , Debug , RustcEncodable , RustcDecodable ) ]
287288pub struct VisibilityScopeInfo {
288289 /// A NodeId with lint levels equivalent to this scope's lint levels.
289290 pub lint_root : ast:: NodeId ,
290291 /// The unsafe block that contains this node.
291292 pub safety : Safety ,
292293}
293294
294- #[ derive( Copy , Clone , Debug ) ]
295+ #[ derive( Copy , Clone , Debug , RustcEncodable , RustcDecodable ) ]
295296pub enum Safety {
296297 Safe ,
297298 /// Unsafe because of a PushUnsafeBlock
@@ -335,22 +336,13 @@ impl<'tcx> IndexMut<BasicBlock> for Mir<'tcx> {
335336}
336337
337338#[ derive( Clone , Debug ) ]
338- pub enum ClearOnDecode < T > {
339+ pub enum ClearCrossCrate < T > {
339340 Clear ,
340341 Set ( T )
341342}
342343
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 > { }
354346
355347/// Grouped information about the source code origin of a MIR entity.
356348/// Intended to be inspected by diagnostics and debuginfo.
@@ -1733,21 +1725,21 @@ impl Location {
17331725 }
17341726}
17351727
1736- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
1728+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
17371729pub enum UnsafetyViolationKind {
17381730 General ,
17391731 ExternStatic ( ast:: NodeId ) ,
17401732 BorrowPacked ( ast:: NodeId ) ,
17411733}
17421734
1743- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
1735+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
17441736pub struct UnsafetyViolation {
17451737 pub source_info : SourceInfo ,
1746- pub description : & ' static str ,
1738+ pub description : InternedString ,
17471739 pub kind : UnsafetyViolationKind ,
17481740}
17491741
1750- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
1742+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
17511743pub struct UnsafetyCheckResult {
17521744 /// Violations that are propagated *upwards* from this function
17531745 pub violations : Rc < [ UnsafetyViolation ] > ,
0 commit comments