@@ -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
@@ -1373,7 +1327,7 @@ impl<'tcx> TyCtxt<'tcx> {
13731327 let caller_features = & self . body_codegen_attrs ( caller) . target_features ;
13741328 if self . is_target_feature_call_safe ( & fun_features, & caller_features) {
13751329 return Some ( fun_sig. map_bound ( |sig| ty:: FnSig {
1376- fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safe ( true ) ,
1330+ fn_sig_kind : fun_sig. fn_sig_kind ( ) . set_safety ( hir :: Safety :: Safe ) ,
13771331 ..sig
13781332 } ) ) ;
13791333 }
@@ -2142,7 +2096,10 @@ impl<'tcx> TyCtxt<'tcx> {
21422096 assert ! ( sig. safety( ) . is_safe( ) ) ;
21432097 Ty :: new_fn_ptr (
21442098 self ,
2145- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } ) ,
2099+ sig. map_bound ( |sig| ty:: FnSig {
2100+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2101+ ..sig
2102+ } ) ,
21462103 )
21472104 }
21482105
@@ -2151,7 +2108,10 @@ impl<'tcx> TyCtxt<'tcx> {
21512108 /// unsafe.
21522109 pub fn safe_to_unsafe_sig ( self , sig : PolyFnSig < ' tcx > ) -> PolyFnSig < ' tcx > {
21532110 assert ! ( sig. safety( ) . is_safe( ) ) ;
2154- sig. map_bound ( |sig| ty:: FnSig { fn_sig_kind : sig. fn_sig_kind . set_safe ( false ) , ..sig } )
2111+ sig. map_bound ( |sig| ty:: FnSig {
2112+ fn_sig_kind : sig. fn_sig_kind . set_safety ( hir:: Safety :: Unsafe ) ,
2113+ ..sig
2114+ } )
21552115 }
21562116
21572117 /// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
@@ -2196,7 +2156,7 @@ impl<'tcx> TyCtxt<'tcx> {
21962156 self . mk_fn_sig (
21972157 params,
21982158 s. output ( ) ,
2199- s. fn_sig_kind . set_safe ( safety. is_safe ( ) ) . set_abi ( ExternAbi :: Rust ) ,
2159+ s. fn_sig_kind . set_safety ( safety) . set_abi ( ExternAbi :: Rust ) ,
22002160 )
22012161 } )
22022162 }
@@ -2470,7 +2430,12 @@ impl<'tcx> TyCtxt<'tcx> {
24702430 // IntoIterator` instead of `I: Iterator`, and it doesn't have a slice
24712431 // variant, because of the need to combine `inputs` and `output`. This
24722432 // explains the lack of `_from_iter` suffix.
2473- pub fn mk_fn_sig < I , T > ( self , inputs : I , output : I :: Item , fn_sig_kind : FnSigKind ) -> T :: Output
2433+ pub fn mk_fn_sig < I , T > (
2434+ self ,
2435+ inputs : I ,
2436+ output : I :: Item ,
2437+ fn_sig_kind : FnSigKind < ' tcx > ,
2438+ ) -> T :: Output
24742439 where
24752440 I : IntoIterator < Item = T > ,
24762441 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
@@ -2492,7 +2457,7 @@ impl<'tcx> TyCtxt<'tcx> {
24922457 I : IntoIterator < Item = T > ,
24932458 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
24942459 {
2495- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( safety. is_safe ( ) ) )
2460+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( safety) )
24962461 }
24972462
24982463 /// `mk_fn_sig`, but with a safe Rust ABI, and no C-variadic argument.
@@ -2501,7 +2466,7 @@ impl<'tcx> TyCtxt<'tcx> {
25012466 I : IntoIterator < Item = T > ,
25022467 T : CollectAndApply < Ty < ' tcx > , ty:: FnSig < ' tcx > > ,
25032468 {
2504- self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safe ( true ) )
2469+ self . mk_fn_sig ( inputs, output, FnSigKind :: default ( ) . set_safety ( hir :: Safety :: Safe ) )
25052470 }
25062471
25072472 pub fn mk_poly_existential_predicates_from_iter < I , T > ( self , iter : I ) -> T :: Output
0 commit comments