@@ -365,26 +365,26 @@ impl<'a, 'tcx> TyEncoder for EncodeContext<'a, 'tcx> {
365
365
}
366
366
}
367
367
368
- // Shorthand for `$self.$tables.$table.set ($def_id.index, $self.lazy_value($value))`, which would
368
+ // Shorthand for `$self.$tables.$table.set_some ($def_id.index, $self.lazy_value($value))`, which would
369
369
// normally need extra variables to avoid errors about multiple mutable borrows.
370
370
macro_rules! record {
371
371
( $self: ident. $tables: ident. $table: ident[ $def_id: expr] <- $value: expr) => { {
372
372
{
373
373
let value = $value;
374
374
let lazy = $self. lazy( value) ;
375
- $self. $tables. $table. set ( $def_id. index, lazy) ;
375
+ $self. $tables. $table. set_some ( $def_id. index, lazy) ;
376
376
}
377
377
} } ;
378
378
}
379
379
380
- // Shorthand for `$self.$tables.$table.set ($def_id.index, $self.lazy_value($value))`, which would
380
+ // Shorthand for `$self.$tables.$table.set_some ($def_id.index, $self.lazy_value($value))`, which would
381
381
// normally need extra variables to avoid errors about multiple mutable borrows.
382
382
macro_rules! record_array {
383
383
( $self: ident. $tables: ident. $table: ident[ $def_id: expr] <- $value: expr) => { {
384
384
{
385
385
let value = $value;
386
386
let lazy = $self. lazy_array( value) ;
387
- $self. $tables. $table. set ( $def_id. index, lazy) ;
387
+ $self. $tables. $table. set_some ( $def_id. index, lazy) ;
388
388
}
389
389
} } ;
390
390
}
@@ -467,14 +467,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
467
467
{
468
468
let def_key = self . lazy ( table. def_key ( def_index) ) ;
469
469
let def_path_hash = table. def_path_hash ( def_index) ;
470
- self . tables . def_keys . set ( def_index, def_key) ;
471
- self . tables . def_path_hashes . set ( def_index, def_path_hash) ;
470
+ self . tables . def_keys . set_some ( def_index, def_key) ;
471
+ self . tables . def_path_hashes . set_some ( def_index, def_path_hash) ;
472
472
}
473
473
} else {
474
474
for ( def_index, def_key, def_path_hash) in table. enumerated_keys_and_path_hashes ( ) {
475
475
let def_key = self . lazy ( def_key) ;
476
- self . tables . def_keys . set ( def_index, def_key) ;
477
- self . tables . def_path_hashes . set ( def_index, * def_path_hash) ;
476
+ self . tables . def_keys . set_some ( def_index, def_key) ;
477
+ self . tables . def_path_hashes . set_some ( def_index, * def_path_hash) ;
478
478
}
479
479
}
480
480
}
@@ -548,7 +548,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
548
548
549
549
let on_disk_index: u32 =
550
550
on_disk_index. try_into ( ) . expect ( "cannot export more than U32_MAX files" ) ;
551
- adapted. set ( on_disk_index, self . lazy ( source_file) ) ;
551
+ adapted. set_some ( on_disk_index, self . lazy ( source_file) ) ;
552
552
}
553
553
554
554
adapted. encode ( & mut self . opaque )
@@ -1147,9 +1147,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1147
1147
if state. is_doc_hidden {
1148
1148
attr_flags |= AttrFlags :: IS_DOC_HIDDEN ;
1149
1149
}
1150
- if !attr_flags. is_empty ( ) {
1151
- self . tables . attr_flags . set_nullable ( def_id. local_def_index , attr_flags) ;
1152
- }
1150
+ self . tables . attr_flags . set ( def_id. local_def_index , attr_flags) ;
1153
1151
}
1154
1152
1155
1153
fn encode_def_ids ( & mut self ) {
@@ -1161,7 +1159,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1161
1159
let def_id = local_id. to_def_id ( ) ;
1162
1160
let def_kind = tcx. opt_def_kind ( local_id) ;
1163
1161
let Some ( def_kind) = def_kind else { continue } ;
1164
- self . tables . opt_def_kind . set ( def_id. index , def_kind) ;
1162
+ self . tables . opt_def_kind . set_some ( def_id. index , def_kind) ;
1165
1163
let def_span = tcx. def_span ( local_id) ;
1166
1164
record ! ( self . tables. def_span[ def_id] <- def_span) ;
1167
1165
self . encode_attrs ( local_id) ;
@@ -1264,14 +1262,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1264
1262
} ;
1265
1263
record ! ( self . tables. variant_data[ variant. def_id] <- data) ;
1266
1264
1267
- self . tables . constness . set ( variant. def_id . index , hir:: Constness :: Const ) ;
1265
+ self . tables . constness . set_some ( variant. def_id . index , hir:: Constness :: Const ) ;
1268
1266
record_array ! ( self . tables. children[ variant. def_id] <- variant. fields. iter( ) . map( |f| {
1269
1267
assert!( f. did. is_local( ) ) ;
1270
1268
f. did. index
1271
1269
} ) ) ;
1272
1270
1273
1271
if let Some ( ( CtorKind :: Fn , ctor_def_id) ) = variant. ctor {
1274
- self . tables . constness . set ( ctor_def_id. index , hir:: Constness :: Const ) ;
1272
+ self . tables . constness . set_some ( ctor_def_id. index , hir:: Constness :: Const ) ;
1275
1273
let fn_sig = tcx. fn_sig ( ctor_def_id) ;
1276
1274
record ! ( self . tables. fn_sig[ ctor_def_id] <- fn_sig) ;
1277
1275
// FIXME only encode signature for ctor_def_id
@@ -1342,16 +1340,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1342
1340
let tcx = self . tcx ;
1343
1341
1344
1342
let impl_defaultness = tcx. impl_defaultness ( def_id. expect_local ( ) ) ;
1345
- self . tables . impl_defaultness . set ( def_id. index , impl_defaultness) ;
1343
+ self . tables . impl_defaultness . set_some ( def_id. index , impl_defaultness) ;
1346
1344
let trait_item = tcx. associated_item ( def_id) ;
1347
- self . tables . assoc_container . set ( def_id. index , trait_item. container ) ;
1345
+ self . tables . assoc_container . set_some ( def_id. index , trait_item. container ) ;
1348
1346
1349
1347
match trait_item. kind {
1350
1348
ty:: AssocKind :: Const => { }
1351
1349
ty:: AssocKind :: Fn => {
1352
1350
record_array ! ( self . tables. fn_arg_names[ def_id] <- tcx. fn_arg_names( def_id) ) ;
1353
- self . tables . asyncness . set ( def_id. index , tcx. asyncness ( def_id) ) ;
1354
- self . tables . constness . set ( def_id. index , hir:: Constness :: NotConst ) ;
1351
+ self . tables . asyncness . set_some ( def_id. index , tcx. asyncness ( def_id) ) ;
1352
+ self . tables . constness . set_some ( def_id. index , hir:: Constness :: NotConst ) ;
1355
1353
}
1356
1354
ty:: AssocKind :: Type => {
1357
1355
self . encode_explicit_item_bounds ( def_id) ;
@@ -1367,33 +1365,31 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1367
1365
let tcx = self . tcx ;
1368
1366
1369
1367
let ast_item = self . tcx . hir ( ) . expect_impl_item ( def_id. expect_local ( ) ) ;
1370
- self . tables . impl_defaultness . set ( def_id. index , ast_item. defaultness ) ;
1368
+ self . tables . impl_defaultness . set_some ( def_id. index , ast_item. defaultness ) ;
1371
1369
let impl_item = self . tcx . associated_item ( def_id) ;
1372
- self . tables . assoc_container . set ( def_id. index , impl_item. container ) ;
1370
+ self . tables . assoc_container . set_some ( def_id. index , impl_item. container ) ;
1373
1371
1374
1372
match impl_item. kind {
1375
1373
ty:: AssocKind :: Fn => {
1376
1374
let hir:: ImplItemKind :: Fn ( ref sig, body) = ast_item. kind else { bug ! ( ) } ;
1377
- self . tables . asyncness . set ( def_id. index , sig. header . asyncness ) ;
1375
+ self . tables . asyncness . set_some ( def_id. index , sig. header . asyncness ) ;
1378
1376
record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1379
1377
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1380
1378
let constness = if self . tcx . is_const_fn_raw ( def_id) {
1381
1379
hir:: Constness :: Const
1382
1380
} else {
1383
1381
hir:: Constness :: NotConst
1384
1382
} ;
1385
- self . tables . constness . set ( def_id. index , constness) ;
1383
+ self . tables . constness . set_some ( def_id. index , constness) ;
1386
1384
}
1387
1385
ty:: AssocKind :: Const | ty:: AssocKind :: Type => { }
1388
1386
}
1389
1387
if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
1390
- self . tables . trait_item_def_id . set ( def_id. index , trait_item_def_id. into ( ) ) ;
1388
+ self . tables . trait_item_def_id . set_some ( def_id. index , trait_item_def_id. into ( ) ) ;
1391
1389
}
1392
1390
if impl_item. kind == ty:: AssocKind :: Fn {
1393
1391
record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1394
- if tcx. is_intrinsic ( def_id) {
1395
- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1396
- }
1392
+ self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1397
1393
}
1398
1394
}
1399
1395
@@ -1522,35 +1518,33 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1522
1518
1523
1519
match item. kind {
1524
1520
hir:: ItemKind :: Fn ( ref sig, .., body) => {
1525
- self . tables . asyncness . set ( def_id. index , sig. header . asyncness ) ;
1521
+ self . tables . asyncness . set_some ( def_id. index , sig. header . asyncness ) ;
1526
1522
record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1527
- self . tables . constness . set ( def_id. index , sig. header . constness ) ;
1523
+ self . tables . constness . set_some ( def_id. index , sig. header . constness ) ;
1528
1524
}
1529
1525
hir:: ItemKind :: Macro ( ref macro_def, _) => {
1530
- if macro_def. macro_rules {
1531
- self . tables . is_macro_rules . set_nullable ( def_id. index , true ) ;
1532
- }
1526
+ self . tables . is_macro_rules . set ( def_id. index , macro_def. macro_rules ) ;
1533
1527
record ! ( self . tables. macro_definition[ def_id] <- & * macro_def. body) ;
1534
1528
}
1535
1529
hir:: ItemKind :: Mod ( ref m) => {
1536
1530
return self . encode_info_for_mod ( item. owner_id . def_id , m) ;
1537
1531
}
1538
1532
hir:: ItemKind :: OpaqueTy ( ref opaque) => {
1539
1533
self . encode_explicit_item_bounds ( def_id) ;
1540
- if matches ! ( opaque . origin , hir :: OpaqueTyOrigin :: TyAlias ) {
1541
- self . tables . is_type_alias_impl_trait . set_nullable ( def_id . index , true ) ;
1542
- }
1534
+ self . tables
1535
+ . is_type_alias_impl_trait
1536
+ . set ( def_id . index , matches ! ( opaque . origin , hir :: OpaqueTyOrigin :: TyAlias ) ) ;
1543
1537
}
1544
1538
hir:: ItemKind :: Impl ( hir:: Impl { defaultness, constness, .. } ) => {
1545
- self . tables . impl_defaultness . set ( def_id. index , * defaultness) ;
1546
- self . tables . constness . set ( def_id. index , * constness) ;
1539
+ self . tables . impl_defaultness . set_some ( def_id. index , * defaultness) ;
1540
+ self . tables . constness . set_some ( def_id. index , * constness) ;
1547
1541
1548
1542
let trait_ref = self . tcx . impl_trait_ref ( def_id) . map ( ty:: EarlyBinder :: skip_binder) ;
1549
1543
if let Some ( trait_ref) = trait_ref {
1550
1544
let trait_def = self . tcx . trait_def ( trait_ref. def_id ) ;
1551
1545
if let Ok ( mut an) = trait_def. ancestors ( self . tcx , def_id) {
1552
1546
if let Some ( specialization_graph:: Node :: Impl ( parent) ) = an. nth ( 1 ) {
1553
- self . tables . impl_parent . set ( def_id. index , parent. into ( ) ) ;
1547
+ self . tables . impl_parent . set_some ( def_id. index , parent. into ( ) ) ;
1554
1548
}
1555
1549
}
1556
1550
@@ -1564,7 +1558,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1564
1558
}
1565
1559
1566
1560
let polarity = self . tcx . impl_polarity ( def_id) ;
1567
- self . tables . impl_polarity . set ( def_id. index , polarity) ;
1561
+ self . tables . impl_polarity . set_some ( def_id. index , polarity) ;
1568
1562
}
1569
1563
hir:: ItemKind :: Trait ( ..) => {
1570
1564
let trait_def = self . tcx . trait_def ( def_id) ;
@@ -1601,9 +1595,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1601
1595
}
1602
1596
if let hir:: ItemKind :: Fn ( ..) = item. kind {
1603
1597
record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1604
- if tcx. is_intrinsic ( def_id) {
1605
- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1606
- }
1598
+ self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1607
1599
}
1608
1600
if let hir:: ItemKind :: Impl { .. } = item. kind {
1609
1601
if let Some ( trait_ref) = self . tcx . impl_trait_ref ( def_id) {
@@ -1650,7 +1642,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1650
1642
1651
1643
ty:: Closure ( _, substs) => {
1652
1644
let constness = self . tcx . constness ( def_id. to_def_id ( ) ) ;
1653
- self . tables . constness . set ( def_id. to_def_id ( ) . index , constness) ;
1645
+ self . tables . constness . set_some ( def_id. to_def_id ( ) . index , constness) ;
1654
1646
record ! ( self . tables. fn_sig[ def_id. to_def_id( ) ] <- ty:: EarlyBinder ( substs. as_closure( ) . sig( ) ) ) ;
1655
1647
}
1656
1648
@@ -1678,12 +1670,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1678
1670
self . hygiene_ctxt . encode (
1679
1671
& mut ( & mut * self , & mut syntax_contexts, & mut expn_data_table, & mut expn_hash_table) ,
1680
1672
|( this, syntax_contexts, _, _) , index, ctxt_data| {
1681
- syntax_contexts. set ( index, this. lazy ( ctxt_data) ) ;
1673
+ syntax_contexts. set_some ( index, this. lazy ( ctxt_data) ) ;
1682
1674
} ,
1683
1675
|( this, _, expn_data_table, expn_hash_table) , index, expn_data, hash| {
1684
1676
if let Some ( index) = index. as_local ( ) {
1685
- expn_data_table. set ( index. as_raw ( ) , this. lazy ( expn_data) ) ;
1686
- expn_hash_table. set ( index. as_raw ( ) , this. lazy ( hash) ) ;
1677
+ expn_data_table. set_some ( index. as_raw ( ) , this. lazy ( expn_data) ) ;
1678
+ expn_hash_table. set_some ( index. as_raw ( ) , this. lazy ( hash) ) ;
1687
1679
}
1688
1680
} ,
1689
1681
) ;
@@ -1708,10 +1700,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1708
1700
let spans = self . tcx . sess . parse_sess . proc_macro_quoted_spans ( ) ;
1709
1701
for ( i, span) in spans. into_iter ( ) . enumerate ( ) {
1710
1702
let span = self . lazy ( span) ;
1711
- self . tables . proc_macro_quoted_spans . set ( i, span) ;
1703
+ self . tables . proc_macro_quoted_spans . set_some ( i, span) ;
1712
1704
}
1713
1705
1714
- self . tables . opt_def_kind . set ( LOCAL_CRATE . as_def_id ( ) . index , DefKind :: Mod ) ;
1706
+ self . tables . opt_def_kind . set_some ( LOCAL_CRATE . as_def_id ( ) . index , DefKind :: Mod ) ;
1715
1707
record ! ( self . tables. def_span[ LOCAL_CRATE . as_def_id( ) ] <- tcx. def_span( LOCAL_CRATE . as_def_id( ) ) ) ;
1716
1708
self . encode_attrs ( LOCAL_CRATE . as_def_id ( ) . expect_local ( ) ) ;
1717
1709
let vis = tcx. local_visibility ( CRATE_DEF_ID ) . map_id ( |def_id| def_id. local_def_index ) ;
@@ -1753,8 +1745,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1753
1745
def_key. disambiguated_data . data = DefPathData :: MacroNs ( name) ;
1754
1746
1755
1747
let def_id = id. to_def_id ( ) ;
1756
- self . tables . opt_def_kind . set ( def_id. index , DefKind :: Macro ( macro_kind) ) ;
1757
- self . tables . proc_macro . set ( def_id. index , macro_kind) ;
1748
+ self . tables . opt_def_kind . set_some ( def_id. index , DefKind :: Macro ( macro_kind) ) ;
1749
+ self . tables . proc_macro . set_some ( def_id. index , macro_kind) ;
1758
1750
self . encode_attrs ( id) ;
1759
1751
record ! ( self . tables. def_keys[ def_id] <- def_key) ;
1760
1752
record ! ( self . tables. def_ident_span[ def_id] <- span) ;
@@ -1979,22 +1971,20 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1979
1971
1980
1972
match nitem. kind {
1981
1973
hir:: ForeignItemKind :: Fn ( _, ref names, _) => {
1982
- self . tables . asyncness . set ( def_id. index , hir:: IsAsync :: NotAsync ) ;
1974
+ self . tables . asyncness . set_some ( def_id. index , hir:: IsAsync :: NotAsync ) ;
1983
1975
record_array ! ( self . tables. fn_arg_names[ def_id] <- * names) ;
1984
1976
let constness = if self . tcx . is_const_fn_raw ( def_id) {
1985
1977
hir:: Constness :: Const
1986
1978
} else {
1987
1979
hir:: Constness :: NotConst
1988
1980
} ;
1989
- self . tables . constness . set ( def_id. index , constness) ;
1981
+ self . tables . constness . set_some ( def_id. index , constness) ;
1990
1982
record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1991
1983
}
1992
1984
hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => { }
1993
1985
}
1994
1986
if let hir:: ForeignItemKind :: Fn ( ..) = nitem. kind {
1995
- if tcx. is_intrinsic ( def_id) {
1996
- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1997
- }
1987
+ self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1998
1988
}
1999
1989
}
2000
1990
}
0 commit comments