@@ -7,17 +7,8 @@ use std::collections::HashSet;
7
7
8
8
use crate :: kani_queries:: QueryDb ;
9
9
use rustc_hir:: { def:: DefKind , def_id:: DefId as InternalDefId , def_id:: LOCAL_CRATE } ;
10
- use rustc_middle:: span_bug;
11
- use rustc_middle:: ty:: layout:: {
12
- FnAbiError , FnAbiOf , FnAbiOfHelpers , FnAbiRequest , HasParamEnv , HasTyCtxt , LayoutError ,
13
- LayoutOfHelpers , TyAndLayout ,
14
- } ;
15
- use rustc_middle:: ty:: { self , Instance as InstanceInternal , Ty as TyInternal , TyCtxt } ;
10
+ use rustc_middle:: ty:: TyCtxt ;
16
11
use rustc_smir:: rustc_internal;
17
- use rustc_span:: Span ;
18
- use rustc_span:: source_map:: respan;
19
- use rustc_target:: abi:: call:: FnAbi ;
20
- use rustc_target:: abi:: { HasDataLayout , TargetDataLayout } ;
21
12
use stable_mir:: CrateDef ;
22
13
use stable_mir:: mir:: mono:: MonoItem ;
23
14
use stable_mir:: ty:: { FnDef , RigidTy , Span as SpanStable , Ty , TyKind } ;
@@ -155,80 +146,6 @@ impl SourceLocation {
155
146
}
156
147
}
157
148
158
- /// Get the FnAbi of a given instance with no extra variadic arguments.
159
- /// TODO: Get rid of this. Use instance.fn_abi() instead.
160
- /// <https://github.com/model-checking/kani/issues/1365>
161
- pub fn fn_abi < ' tcx > (
162
- tcx : TyCtxt < ' tcx > ,
163
- instance : InstanceInternal < ' tcx > ,
164
- ) -> & ' tcx FnAbi < ' tcx , TyInternal < ' tcx > > {
165
- let helper = CompilerHelpers { tcx } ;
166
- helper. fn_abi_of_instance ( instance, ty:: List :: empty ( ) )
167
- }
168
-
169
- struct CompilerHelpers < ' tcx > {
170
- tcx : TyCtxt < ' tcx > ,
171
- }
172
-
173
- impl < ' tcx > HasParamEnv < ' tcx > for CompilerHelpers < ' tcx > {
174
- fn param_env ( & self ) -> ty:: ParamEnv < ' tcx > {
175
- ty:: ParamEnv :: reveal_all ( )
176
- }
177
- }
178
-
179
- impl < ' tcx > HasTyCtxt < ' tcx > for CompilerHelpers < ' tcx > {
180
- fn tcx ( & self ) -> TyCtxt < ' tcx > {
181
- self . tcx
182
- }
183
- }
184
-
185
- impl HasDataLayout for CompilerHelpers < ' _ > {
186
- fn data_layout ( & self ) -> & TargetDataLayout {
187
- self . tcx . data_layout ( )
188
- }
189
- }
190
-
191
- impl < ' tcx > LayoutOfHelpers < ' tcx > for CompilerHelpers < ' tcx > {
192
- type LayoutOfResult = TyAndLayout < ' tcx > ;
193
-
194
- #[ inline]
195
- fn handle_layout_err ( & self , err : LayoutError < ' tcx > , span : Span , ty : TyInternal < ' tcx > ) -> ! {
196
- span_bug ! ( span, "failed to get layout for `{}`: {}" , ty, err)
197
- }
198
- }
199
-
200
- /// Implement error handling for extracting function ABI information.
201
- impl < ' tcx > FnAbiOfHelpers < ' tcx > for CompilerHelpers < ' tcx > {
202
- type FnAbiOfResult = & ' tcx FnAbi < ' tcx , TyInternal < ' tcx > > ;
203
-
204
- #[ inline]
205
- fn handle_fn_abi_err (
206
- & self ,
207
- err : FnAbiError < ' tcx > ,
208
- span : Span ,
209
- fn_abi_request : FnAbiRequest < ' tcx > ,
210
- ) -> ! {
211
- if let FnAbiError :: Layout ( LayoutError :: SizeOverflow ( _) ) = err {
212
- self . tcx . dcx ( ) . emit_fatal ( respan ( span, err) )
213
- } else {
214
- match fn_abi_request {
215
- FnAbiRequest :: OfFnPtr { sig, extra_args } => {
216
- span_bug ! (
217
- span,
218
- "Error: {err:?}\n while running `fn_abi_of_fn_ptr. ({sig}, {extra_args:?})`" ,
219
- ) ;
220
- }
221
- FnAbiRequest :: OfInstance { instance, extra_args } => {
222
- span_bug ! (
223
- span,
224
- "Error: {err:?}\n while running `fn_abi_of_instance. ({instance}, {extra_args:?})`" ,
225
- ) ;
226
- }
227
- }
228
- }
229
- }
230
- }
231
-
232
149
/// Try to convert an internal `DefId` to a `FnDef`.
233
150
pub fn stable_fn_def ( tcx : TyCtxt , def_id : InternalDefId ) -> Option < FnDef > {
234
151
if let TyKind :: RigidTy ( RigidTy :: FnDef ( def, _) ) =
0 commit comments