@@ -365,26 +365,26 @@ impl<'a, 'tcx> TyEncoder for EncodeContext<'a, 'tcx> {
365365 }
366366}
367367
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
369369// normally need extra variables to avoid errors about multiple mutable borrows.
370370macro_rules! record {
371371 ( $self: ident. $tables: ident. $table: ident[ $def_id: expr] <- $value: expr) => { {
372372 {
373373 let value = $value;
374374 let lazy = $self. lazy( value) ;
375- $self. $tables. $table. set ( $def_id. index, lazy) ;
375+ $self. $tables. $table. set_some ( $def_id. index, lazy) ;
376376 }
377377 } } ;
378378}
379379
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
381381// normally need extra variables to avoid errors about multiple mutable borrows.
382382macro_rules! record_array {
383383 ( $self: ident. $tables: ident. $table: ident[ $def_id: expr] <- $value: expr) => { {
384384 {
385385 let value = $value;
386386 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) ;
388388 }
389389 } } ;
390390}
@@ -467,14 +467,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
467467 {
468468 let def_key = self . lazy ( table. def_key ( def_index) ) ;
469469 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) ;
472472 }
473473 } else {
474474 for ( def_index, def_key, def_path_hash) in table. enumerated_keys_and_path_hashes ( ) {
475475 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) ;
478478 }
479479 }
480480 }
@@ -548,7 +548,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
548548
549549 let on_disk_index: u32 =
550550 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) ) ;
552552 }
553553
554554 adapted. encode ( & mut self . opaque )
@@ -1147,9 +1147,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11471147 if state. is_doc_hidden {
11481148 attr_flags |= AttrFlags :: IS_DOC_HIDDEN ;
11491149 }
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) ;
11531151 }
11541152
11551153 fn encode_def_ids ( & mut self ) {
@@ -1161,7 +1159,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11611159 let def_id = local_id. to_def_id ( ) ;
11621160 let def_kind = tcx. opt_def_kind ( local_id) ;
11631161 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) ;
11651163 let def_span = tcx. def_span ( local_id) ;
11661164 record ! ( self . tables. def_span[ def_id] <- def_span) ;
11671165 self . encode_attrs ( local_id) ;
@@ -1264,14 +1262,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12641262 } ;
12651263 record ! ( self . tables. variant_data[ variant. def_id] <- data) ;
12661264
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 ) ;
12681266 record_array ! ( self . tables. children[ variant. def_id] <- variant. fields. iter( ) . map( |f| {
12691267 assert!( f. did. is_local( ) ) ;
12701268 f. did. index
12711269 } ) ) ;
12721270
12731271 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 ) ;
12751273 let fn_sig = tcx. fn_sig ( ctor_def_id) ;
12761274 record ! ( self . tables. fn_sig[ ctor_def_id] <- fn_sig) ;
12771275 // FIXME only encode signature for ctor_def_id
@@ -1342,16 +1340,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13421340 let tcx = self . tcx ;
13431341
13441342 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) ;
13461344 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 ) ;
13481346
13491347 match trait_item. kind {
13501348 ty:: AssocKind :: Const => { }
13511349 ty:: AssocKind :: Fn => {
13521350 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 ) ;
13551353 }
13561354 ty:: AssocKind :: Type => {
13571355 self . encode_explicit_item_bounds ( def_id) ;
@@ -1367,33 +1365,31 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13671365 let tcx = self . tcx ;
13681366
13691367 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 ) ;
13711369 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 ) ;
13731371
13741372 match impl_item. kind {
13751373 ty:: AssocKind :: Fn => {
13761374 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 ) ;
13781376 record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
13791377 // Can be inside `impl const Trait`, so using sig.header.constness is not reliable
13801378 let constness = if self . tcx . is_const_fn_raw ( def_id) {
13811379 hir:: Constness :: Const
13821380 } else {
13831381 hir:: Constness :: NotConst
13841382 } ;
1385- self . tables . constness . set ( def_id. index , constness) ;
1383+ self . tables . constness . set_some ( def_id. index , constness) ;
13861384 }
13871385 ty:: AssocKind :: Const | ty:: AssocKind :: Type => { }
13881386 }
13891387 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 ( ) ) ;
13911389 }
13921390 if impl_item. kind == ty:: AssocKind :: Fn {
13931391 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) ) ;
13971393 }
13981394 }
13991395
@@ -1522,35 +1518,33 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15221518
15231519 match item. kind {
15241520 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 ) ;
15261522 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 ) ;
15281524 }
15291525 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 ) ;
15331527 record ! ( self . tables. macro_definition[ def_id] <- & * macro_def. body) ;
15341528 }
15351529 hir:: ItemKind :: Mod ( ref m) => {
15361530 return self . encode_info_for_mod ( item. owner_id . def_id , m) ;
15371531 }
15381532 hir:: ItemKind :: OpaqueTy ( ref opaque) => {
15391533 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 ) ) ;
15431537 }
15441538 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) ;
15471541
15481542 let trait_ref = self . tcx . impl_trait_ref ( def_id) . map ( ty:: EarlyBinder :: skip_binder) ;
15491543 if let Some ( trait_ref) = trait_ref {
15501544 let trait_def = self . tcx . trait_def ( trait_ref. def_id ) ;
15511545 if let Ok ( mut an) = trait_def. ancestors ( self . tcx , def_id) {
15521546 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 ( ) ) ;
15541548 }
15551549 }
15561550
@@ -1564,7 +1558,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15641558 }
15651559
15661560 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) ;
15681562 }
15691563 hir:: ItemKind :: Trait ( ..) => {
15701564 let trait_def = self . tcx . trait_def ( def_id) ;
@@ -1601,9 +1595,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16011595 }
16021596 if let hir:: ItemKind :: Fn ( ..) = item. kind {
16031597 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) ) ;
16071599 }
16081600 if let hir:: ItemKind :: Impl { .. } = item. kind {
16091601 if let Some ( trait_ref) = self . tcx . impl_trait_ref ( def_id) {
@@ -1650,7 +1642,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16501642
16511643 ty:: Closure ( _, substs) => {
16521644 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) ;
16541646 record ! ( self . tables. fn_sig[ def_id. to_def_id( ) ] <- ty:: EarlyBinder ( substs. as_closure( ) . sig( ) ) ) ;
16551647 }
16561648
@@ -1678,12 +1670,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16781670 self . hygiene_ctxt . encode (
16791671 & mut ( & mut * self , & mut syntax_contexts, & mut expn_data_table, & mut expn_hash_table) ,
16801672 |( 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) ) ;
16821674 } ,
16831675 |( this, _, expn_data_table, expn_hash_table) , index, expn_data, hash| {
16841676 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) ) ;
16871679 }
16881680 } ,
16891681 ) ;
@@ -1708,10 +1700,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17081700 let spans = self . tcx . sess . parse_sess . proc_macro_quoted_spans ( ) ;
17091701 for ( i, span) in spans. into_iter ( ) . enumerate ( ) {
17101702 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) ;
17121704 }
17131705
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 ) ;
17151707 record ! ( self . tables. def_span[ LOCAL_CRATE . as_def_id( ) ] <- tcx. def_span( LOCAL_CRATE . as_def_id( ) ) ) ;
17161708 self . encode_attrs ( LOCAL_CRATE . as_def_id ( ) . expect_local ( ) ) ;
17171709 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> {
17531745 def_key. disambiguated_data . data = DefPathData :: MacroNs ( name) ;
17541746
17551747 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) ;
17581750 self . encode_attrs ( id) ;
17591751 record ! ( self . tables. def_keys[ def_id] <- def_key) ;
17601752 record ! ( self . tables. def_ident_span[ def_id] <- span) ;
@@ -1979,22 +1971,20 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19791971
19801972 match nitem. kind {
19811973 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 ) ;
19831975 record_array ! ( self . tables. fn_arg_names[ def_id] <- * names) ;
19841976 let constness = if self . tcx . is_const_fn_raw ( def_id) {
19851977 hir:: Constness :: Const
19861978 } else {
19871979 hir:: Constness :: NotConst
19881980 } ;
1989- self . tables . constness . set ( def_id. index , constness) ;
1981+ self . tables . constness . set_some ( def_id. index , constness) ;
19901982 record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
19911983 }
19921984 hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => { }
19931985 }
19941986 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) ) ;
19981988 }
19991989 }
20001990}
0 commit comments