@@ -1188,13 +1188,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1188
1188
& ( & self . tcx . hir ( ) as & dyn intravisit:: Map < ' _ > ) ,
1189
1189
|s| s. print_trait_item ( ast_item) ,
1190
1190
) ;
1191
- let rendered_const = self . lazy ( RenderedConst ( rendered) ) ;
1192
1191
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) ) ;
1197
1193
record ! ( self . tables. mir_const_qualif[ def_id] <- mir:: ConstQualifs :: default ( ) ) ;
1194
+ record ! ( self . tables. rendered_const[ def_id] <- rendered) ;
1198
1195
}
1199
1196
ty:: AssocKind :: Fn => {
1200
1197
let fn_data = if let hir:: TraitItemKind :: Fn ( m_sig, m) = & ast_item. kind {
@@ -1256,12 +1253,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1256
1253
ty:: AssocKind :: Const => {
1257
1254
if let hir:: ImplItemKind :: Const ( _, body_id) = ast_item. kind {
1258
1255
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) ;
1259
1257
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) ) ;
1264
1259
record ! ( self . tables. mir_const_qualif[ def_id] <- qualifs) ;
1260
+ record ! ( self . tables. rendered_const[ def_id] <- const_data) ;
1265
1261
} else {
1266
1262
bug ! ( )
1267
1263
}
@@ -1385,14 +1381,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1385
1381
}
1386
1382
}
1387
1383
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 {
1389
1385
let hir = self . tcx . hir ( ) ;
1390
1386
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| {
1392
1388
s. print_expr ( & body. value )
1393
- } ) ;
1394
- let rendered_const = & RenderedConst ( rendered) ;
1395
- self . lazy ( rendered_const)
1389
+ } )
1396
1390
}
1397
1391
1398
1392
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> {
1407
1401
hir:: ItemKind :: Static ( _, hir:: Mutability :: Not , _) => EntryKind :: ImmStatic ,
1408
1402
hir:: ItemKind :: Const ( _, body_id) => {
1409
1403
let qualifs = self . tcx . at ( item. span ) . mir_const_qualif ( def_id) ;
1404
+ let const_data = self . encode_rendered_const_for_body ( body_id) ;
1410
1405
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
1412
1408
}
1413
1409
hir:: ItemKind :: Fn ( ref sig, .., body) => {
1414
1410
let data = FnData {
@@ -1604,8 +1600,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1604
1600
let const_data = self . encode_rendered_const_for_body ( body_id) ;
1605
1601
let qualifs = self . tcx . mir_const_qualif ( def_id) ;
1606
1602
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 ) ;
1608
1604
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) ;
1609
1606
self . encode_item_type ( def_id. to_def_id ( ) ) ;
1610
1607
}
1611
1608
0 commit comments