@@ -1188,13 +1188,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11881188 & ( & self . tcx . hir ( ) as & dyn intravisit:: Map < ' _ > ) ,
11891189 |s| s. print_trait_item ( ast_item) ,
11901190 ) ;
1191- let rendered_const = self . lazy ( RenderedConst ( rendered) ) ;
11921191
1193- record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocConst (
1194- container,
1195- rendered_const,
1196- ) ) ;
1192+ record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocConst ( container) ) ;
11971193 record ! ( self . tables. mir_const_qualif[ def_id] <- mir:: ConstQualifs :: default ( ) ) ;
1194+ record ! ( self . tables. rendered_const[ def_id] <- rendered) ;
11981195 }
11991196 ty:: AssocKind :: Fn => {
12001197 let fn_data = if let hir:: TraitItemKind :: Fn ( m_sig, m) = & ast_item. kind {
@@ -1256,12 +1253,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12561253 ty:: AssocKind :: Const => {
12571254 if let hir:: ImplItemKind :: Const ( _, body_id) = ast_item. kind {
12581255 let qualifs = self . tcx . at ( ast_item. span ) . mir_const_qualif ( def_id) ;
1256+ let const_data = self . encode_rendered_const_for_body ( body_id) ;
12591257
1260- record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocConst (
1261- container,
1262- self . encode_rendered_const_for_body( body_id) )
1263- ) ;
1258+ record ! ( self . tables. kind[ def_id] <- EntryKind :: AssocConst ( container) ) ;
12641259 record ! ( self . tables. mir_const_qualif[ def_id] <- qualifs) ;
1260+ record ! ( self . tables. rendered_const[ def_id] <- const_data) ;
12651261 } else {
12661262 bug ! ( )
12671263 }
@@ -1385,14 +1381,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13851381 }
13861382 }
13871383
1388- fn encode_rendered_const_for_body ( & mut self , body_id : hir:: BodyId ) -> Lazy < RenderedConst > {
1384+ fn encode_rendered_const_for_body ( & mut self , body_id : hir:: BodyId ) -> String {
13891385 let hir = self . tcx . hir ( ) ;
13901386 let body = hir. body ( body_id) ;
1391- let rendered = rustc_hir_pretty:: to_string ( & ( & hir as & dyn intravisit:: Map < ' _ > ) , |s| {
1387+ rustc_hir_pretty:: to_string ( & ( & hir as & dyn intravisit:: Map < ' _ > ) , |s| {
13921388 s. print_expr ( & body. value )
1393- } ) ;
1394- let rendered_const = & RenderedConst ( rendered) ;
1395- self . lazy ( rendered_const)
1389+ } )
13961390 }
13971391
13981392 fn encode_info_for_item ( & mut self , def_id : DefId , item : & ' tcx hir:: Item < ' tcx > ) {
@@ -1407,8 +1401,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14071401 hir:: ItemKind :: Static ( _, hir:: Mutability :: Not , _) => EntryKind :: ImmStatic ,
14081402 hir:: ItemKind :: Const ( _, body_id) => {
14091403 let qualifs = self . tcx . at ( item. span ) . mir_const_qualif ( def_id) ;
1404+ let const_data = self . encode_rendered_const_for_body ( body_id) ;
14101405 record ! ( self . tables. mir_const_qualif[ def_id] <- qualifs) ;
1411- EntryKind :: Const ( self . encode_rendered_const_for_body ( body_id) )
1406+ record ! ( self . tables. rendered_const[ def_id] <- const_data) ;
1407+ EntryKind :: Const
14121408 }
14131409 hir:: ItemKind :: Fn ( ref sig, .., body) => {
14141410 let data = FnData {
@@ -1604,8 +1600,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16041600 let const_data = self . encode_rendered_const_for_body ( body_id) ;
16051601 let qualifs = self . tcx . mir_const_qualif ( def_id) ;
16061602
1607- record ! ( self . tables. kind[ def_id. to_def_id( ) ] <- EntryKind :: AnonConst ( const_data ) ) ;
1603+ record ! ( self . tables. kind[ def_id. to_def_id( ) ] <- EntryKind :: AnonConst ) ;
16081604 record ! ( self . tables. mir_const_qualif[ def_id. to_def_id( ) ] <- qualifs) ;
1605+ record ! ( self . tables. rendered_const[ def_id. to_def_id( ) ] <- const_data) ;
16091606 self . encode_item_type ( def_id. to_def_id ( ) ) ;
16101607 }
16111608
0 commit comments