@@ -47,9 +47,7 @@ use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
4747use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
4848use rustc_type_ir:: TyKind :: * ;
4949pub use rustc_type_ir:: lift:: Lift ;
50- use rustc_type_ir:: {
51- CollectAndApply , FnSigKind , TypeFlags , WithCachedTypeInfo , elaborate, search_graph,
52- } ;
50+ use rustc_type_ir:: { CollectAndApply , TypeFlags , WithCachedTypeInfo , elaborate, search_graph} ;
5351use tracing:: { debug, instrument} ;
5452
5553use crate :: arena:: Arena ;
@@ -69,11 +67,11 @@ use crate::traits;
6967use crate :: traits:: solve:: { ExternalConstraints , ExternalConstraintsData , PredefinedOpaques } ;
7068use crate :: ty:: predicate:: ExistentialPredicateStableCmpExt as _;
7169use crate :: ty:: {
72- self , AdtDef , AdtDefData , AdtKind , Binder , Clause , Clauses , Const , GenericArg , GenericArgs ,
73- GenericArgsRef , GenericParamDefKind , List , ListWithCachedTypeInfo , ParamConst , Pattern ,
74- PatternKind , PolyExistentialPredicate , PolyFnSig , Predicate , PredicateKind , PredicatePolarity ,
75- Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyVid , ValTree , ValTreeKind ,
76- Visibility ,
70+ self , AdtDef , AdtDefData , AdtKind , Binder , Clause , Clauses , Const , FnSigKind , GenericArg ,
71+ GenericArgs , GenericArgsRef , GenericParamDefKind , List , ListWithCachedTypeInfo , ParamConst ,
72+ Pattern , PatternKind , PolyExistentialPredicate , PolyFnSig , Predicate , PredicateKind ,
73+ PredicatePolarity , Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyVid ,
74+ ValTree , ValTreeKind , Visibility ,
7775} ;
7876
7977impl < ' tcx > rustc_type_ir:: inherent:: DefId < TyCtxt < ' tcx > > for DefId {
@@ -86,50 +84,6 @@ impl<'tcx> rustc_type_ir::inherent::DefId<TyCtxt<'tcx>> for DefId {
8684 }
8785}
8886
89- impl < ' tcx > rustc_type_ir:: inherent:: FSigKind < TyCtxt < ' tcx > > for FnSigKind {
90- fn fn_sig_kind ( self ) -> Self {
91- self
92- }
93-
94- fn new ( abi : ExternAbi , safety : hir:: Safety , c_variadic : bool ) -> Self {
95- FnSigKind :: default ( ) . set_abi ( abi) . set_safe ( safety. is_safe ( ) ) . set_c_variadic ( c_variadic)
96- }
97-
98- fn abi ( self ) -> ExternAbi {
99- self . abi ( )
100- }
101-
102- fn safety ( self ) -> hir:: Safety {
103- if self . is_safe ( ) { hir:: Safety :: Safe } else { hir:: Safety :: Unsafe }
104- }
105-
106- fn c_variadic ( self ) -> bool {
107- self . c_variadic ( )
108- }
109- }
110-
111- impl < ' tcx > rustc_type_ir:: inherent:: Abi < TyCtxt < ' tcx > > for ExternAbi {
112- fn abi ( self ) -> Self {
113- self
114- }
115-
116- fn rust ( ) -> Self {
117- ExternAbi :: Rust
118- }
119-
120- fn is_rust ( self ) -> bool {
121- matches ! ( self , ExternAbi :: Rust )
122- }
123-
124- fn pack_abi ( self ) -> u8 {
125- self . as_packed ( )
126- }
127-
128- fn unpack_abi ( abi_index : u8 ) -> Self {
129- Self :: from_packed ( abi_index)
130- }
131- }
132-
13387impl < ' tcx > rustc_type_ir:: inherent:: Safety < TyCtxt < ' tcx > > for hir:: Safety {
13488 fn safe ( ) -> Self {
13589 hir:: Safety :: Safe
@@ -1374,7 +1328,7 @@ impl<'tcx> TyCtxt<'tcx> {
13741328 let caller_features = & self . body_codegen_attrs ( caller) . target_features ;
13751329 if self . is_target_feature_call_safe ( & fun_features, & caller_features) {
13761330 return Some ( fun_sig. map_bound ( |sig| ty:: FnSig {
1377- fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safe ( true ) ,
1331+ fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safety ( hir :: Safety :: Safe ) ,
13781332 ..sig
13791333 } ) ) ;
13801334 }
@@ -2143,7 +2097,10 @@ impl<'tcx> TyCtxt<'tcx> {
21432097 assert ! ( sig. safety( ) . is_safe( ) ) ;
21442098 Ty :: new_fn_ptr (
21452099 self ,
2146- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } ) ,
2100+ sig. map_bound ( |sig| ty:: FnSig {
2101+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2102+ ..sig
2103+ } ) ,
21472104 )
21482105 }
21492106
@@ -2152,7 +2109,10 @@ impl<'tcx> TyCtxt<'tcx> {
21522109 /// unsafe.
21532110 pub fn safe_to_unsafe_sig ( self , sig : PolyFnSig < ' tcx > ) -> PolyFnSig < ' tcx > {
21542111 assert ! ( sig. safety( ) . is_safe( ) ) ;
2155- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } )
2112+ sig. map_bound ( |sig| ty:: FnSig {
2113+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2114+ ..sig
2115+ } )
21562116 }
21572117
21582118 /// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
@@ -2197,7 +2157,7 @@ impl<'tcx> TyCtxt<'tcx> {
21972157 self . mk_fn_sig (
21982158 params,
21992159 s. output ( ) ,
2200- s. fn_sig_kind . set_safe ( safety. is_safe ( ) ) . set_abi ( ExternAbi :: Rust ) ,
2160+ s. fn_sig_kind . set_safety ( safety) . set_abi ( ExternAbi :: Rust ) ,
22012161 )
22022162 } )
22032163 }
@@ -2471,7 +2431,12 @@ impl<'tcx> TyCtxt<'tcx> {
24712431 // IntoIterator` instead of `I: Iterator`, and it doesn't have a slice
24722432 // variant, because of the need to combine `inputs` and `output`. This
24732433 // explains the lack of `_from_iter` suffix.
2474- pub fn mk_fn_sig < I , T > ( self , inputs : I , output : I :: Item , fn_sig_kind : FnSigKind ) -> T :: Output
2434+ pub fn mk_fn_sig < I , T > (
2435+ self ,
2436+ inputs : I ,
2437+ output : I :: Item ,
2438+ fn_sig_kind : FnSigKind < ' tcx > ,
2439+ ) -> T :: Output
24752440 where
24762441 I : IntoIterator < Item = T > ,
24772442 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
@@ -2493,7 +2458,7 @@ impl<'tcx> TyCtxt<'tcx> {
24932458 I : IntoIterator < Item = T > ,
24942459 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
24952460 {
2496- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( safety. is_safe ( ) ) )
2461+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( safety) )
24972462 }
24982463
24992464 /// `mk_fn_sig`, but with a safe Rust ABI, and no C-variadic argument.
@@ -2502,7 +2467,7 @@ impl<'tcx> TyCtxt<'tcx> {
25022467 I : IntoIterator < Item = T > ,
25032468 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
25042469 {
2505- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( true ) )
2470+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( hir :: Safety :: Safe ) )
25062471 }
25072472
25082473 pub fn mk_poly_existential_predicates_from_iter < I , T > ( self , iter : I ) -> T :: Output
0 commit comments