@@ -46,7 +46,7 @@ use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
4646use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
4747use rustc_type_ir:: TyKind :: * ;
4848pub use rustc_type_ir:: lift:: Lift ;
49- use rustc_type_ir:: { CollectAndApply , FnSigKind , WithCachedTypeInfo , elaborate, search_graph} ;
49+ use rustc_type_ir:: { CollectAndApply , WithCachedTypeInfo , elaborate, search_graph} ;
5050use tracing:: { debug, instrument} ;
5151
5252use crate :: arena:: Arena ;
@@ -66,11 +66,11 @@ use crate::traits;
6666use crate :: traits:: solve:: { ExternalConstraints , ExternalConstraintsData , PredefinedOpaques } ;
6767use crate :: ty:: predicate:: ExistentialPredicateStableCmpExt as _;
6868use crate :: ty:: {
69- self , AdtDef , AdtDefData , AdtKind , Binder , Clause , Clauses , Const , GenericArg , GenericArgs ,
70- GenericArgsRef , GenericParamDefKind , List , ListWithCachedTypeInfo , ParamConst , Pattern ,
71- PatternKind , PolyExistentialPredicate , PolyFnSig , Predicate , PredicateKind , PredicatePolarity ,
72- Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyVid , ValTree , ValTreeKind ,
73- Visibility ,
69+ self , AdtDef , AdtDefData , AdtKind , Binder , Clause , Clauses , Const , FnSigKind , GenericArg ,
70+ GenericArgs , GenericArgsRef , GenericParamDefKind , List , ListWithCachedTypeInfo , ParamConst ,
71+ Pattern , PatternKind , PolyExistentialPredicate , PolyFnSig , Predicate , PredicateKind ,
72+ PredicatePolarity , Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyVid ,
73+ ValTree , ValTreeKind , Visibility ,
7474} ;
7575
7676impl < ' tcx > rustc_type_ir:: inherent:: DefId < TyCtxt < ' tcx > > for DefId {
@@ -83,50 +83,6 @@ impl<'tcx> rustc_type_ir::inherent::DefId<TyCtxt<'tcx>> for DefId {
8383 }
8484}
8585
86- impl < ' tcx > rustc_type_ir:: inherent:: FSigKind < TyCtxt < ' tcx > > for FnSigKind {
87- fn fn_sig_kind ( self ) -> Self {
88- self
89- }
90-
91- fn new ( abi : ExternAbi , safety : hir:: Safety , c_variadic : bool ) -> Self {
92- FnSigKind :: default ( ) . set_abi ( abi) . set_safe ( safety. is_safe ( ) ) . set_c_variadic ( c_variadic)
93- }
94-
95- fn abi ( self ) -> ExternAbi {
96- self . abi ( )
97- }
98-
99- fn safety ( self ) -> hir:: Safety {
100- if self . is_safe ( ) { hir:: Safety :: Safe } else { hir:: Safety :: Unsafe }
101- }
102-
103- fn c_variadic ( self ) -> bool {
104- self . c_variadic ( )
105- }
106- }
107-
108- impl < ' tcx > rustc_type_ir:: inherent:: Abi < TyCtxt < ' tcx > > for ExternAbi {
109- fn abi ( self ) -> Self {
110- self
111- }
112-
113- fn rust ( ) -> Self {
114- ExternAbi :: Rust
115- }
116-
117- fn is_rust ( self ) -> bool {
118- matches ! ( self , ExternAbi :: Rust )
119- }
120-
121- fn pack_abi ( self ) -> u8 {
122- self . as_packed ( )
123- }
124-
125- fn unpack_abi ( abi_index : u8 ) -> Self {
126- Self :: from_packed ( abi_index)
127- }
128- }
129-
13086impl < ' tcx > rustc_type_ir:: inherent:: Safety < TyCtxt < ' tcx > > for hir:: Safety {
13187 fn safe ( ) -> Self {
13288 hir:: Safety :: Safe
@@ -1335,7 +1291,7 @@ impl<'tcx> TyCtxt<'tcx> {
13351291 let caller_features = & self . body_codegen_attrs ( caller) . target_features ;
13361292 if self . is_target_feature_call_safe ( & fun_features, & caller_features) {
13371293 return Some ( fun_sig. map_bound ( |sig| ty:: FnSig {
1338- fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safe ( true ) ,
1294+ fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safety ( hir :: Safety :: Safe ) ,
13391295 ..sig
13401296 } ) ) ;
13411297 }
@@ -2104,7 +2060,10 @@ impl<'tcx> TyCtxt<'tcx> {
21042060 assert ! ( sig. safety( ) . is_safe( ) ) ;
21052061 Ty :: new_fn_ptr (
21062062 self ,
2107- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } ) ,
2063+ sig. map_bound ( |sig| ty:: FnSig {
2064+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2065+ ..sig
2066+ } ) ,
21082067 )
21092068 }
21102069
@@ -2113,7 +2072,10 @@ impl<'tcx> TyCtxt<'tcx> {
21132072 /// unsafe.
21142073 pub fn safe_to_unsafe_sig ( self , sig : PolyFnSig < ' tcx > ) -> PolyFnSig < ' tcx > {
21152074 assert ! ( sig. safety( ) . is_safe( ) ) ;
2116- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } )
2075+ sig. map_bound ( |sig| ty:: FnSig {
2076+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2077+ ..sig
2078+ } )
21172079 }
21182080
21192081 /// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
@@ -2158,7 +2120,7 @@ impl<'tcx> TyCtxt<'tcx> {
21582120 self . mk_fn_sig (
21592121 params,
21602122 s. output ( ) ,
2161- s. fn_sig_kind . set_safe ( safety. is_safe ( ) ) . set_abi ( ExternAbi :: Rust ) ,
2123+ s. fn_sig_kind . set_safety ( safety) . set_abi ( ExternAbi :: Rust ) ,
21622124 )
21632125 } )
21642126 }
@@ -2417,7 +2379,12 @@ impl<'tcx> TyCtxt<'tcx> {
24172379 // IntoIterator` instead of `I: Iterator`, and it doesn't have a slice
24182380 // variant, because of the need to combine `inputs` and `output`. This
24192381 // explains the lack of `_from_iter` suffix.
2420- pub fn mk_fn_sig < I , T > ( self , inputs : I , output : I :: Item , fn_sig_kind : FnSigKind ) -> T :: Output
2382+ pub fn mk_fn_sig < I , T > (
2383+ self ,
2384+ inputs : I ,
2385+ output : I :: Item ,
2386+ fn_sig_kind : FnSigKind < ' tcx > ,
2387+ ) -> T :: Output
24212388 where
24222389 I : IntoIterator < Item = T > ,
24232390 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
@@ -2439,7 +2406,7 @@ impl<'tcx> TyCtxt<'tcx> {
24392406 I : IntoIterator < Item = T > ,
24402407 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
24412408 {
2442- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( safety. is_safe ( ) ) )
2409+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( safety) )
24432410 }
24442411
24452412 /// `mk_fn_sig`, but with a safe Rust ABI, and no C-variadic argument.
@@ -2448,7 +2415,7 @@ impl<'tcx> TyCtxt<'tcx> {
24482415 I : IntoIterator < Item = T > ,
24492416 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
24502417 {
2451- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( true ) )
2418+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( hir :: Safety :: Safe ) )
24522419 }
24532420
24542421 pub fn mk_poly_existential_predicates_from_iter < I , T > ( self , iter : I ) -> T :: Output
0 commit comments