|
4 | 4 |
|
5 | 5 | mod simd; |
6 | 6 |
|
7 | | -use rustc_abi::{FIRST_VARIANT, FieldIdx, HasDataLayout, Size, VariantIdx}; |
| 7 | +use rustc_abi::{FieldIdx, HasDataLayout, Size, VariantIdx}; |
8 | 8 | use rustc_apfloat::ieee::{Double, Half, Quad, Single}; |
9 | 9 | use rustc_data_structures::assert_matches; |
10 | 10 | use rustc_errors::msg; |
11 | | -use rustc_hir::def_id::CRATE_DEF_ID; |
12 | | -use rustc_infer::infer::TyCtxtInferExt; |
13 | 11 | use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, read_target_uint, write_target_uint}; |
14 | 12 | use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic}; |
15 | 13 | use rustc_middle::ty::layout::TyAndLayout; |
16 | | -use rustc_middle::ty::{FloatTy, PolyExistentialPredicate, Ty, TyCtxt, TypeVisitableExt}; |
| 14 | +use rustc_middle::ty::{FloatTy, Ty, TyCtxt, TypeVisitableExt}; |
17 | 15 | use rustc_middle::{bug, span_bug, ty}; |
18 | 16 | use rustc_span::{Symbol, sym}; |
19 | | -use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt}; |
20 | 17 | use tracing::trace; |
21 | 18 |
|
22 | 19 | use super::memory::MemoryKind; |
@@ -227,44 +224,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { |
227 | 224 |
|
228 | 225 | self.write_scalar(Scalar::from_target_usize(offset, self), dest)?; |
229 | 226 | } |
230 | | - sym::vtable_for => { |
231 | | - let tp_ty = instance.args.type_at(0); |
232 | | - let result_ty = instance.args.type_at(1); |
233 | | - |
234 | | - ensure_monomorphic_enough(tcx, tp_ty)?; |
235 | | - ensure_monomorphic_enough(tcx, result_ty)?; |
236 | | - let ty::Dynamic(preds, _) = result_ty.kind() else { |
237 | | - span_bug!( |
238 | | - self.find_closest_untracked_caller_location(), |
239 | | - "Invalid type provided to vtable_for::<T, U>. U must be dyn Trait, got {result_ty}." |
240 | | - ); |
241 | | - }; |
242 | | - |
243 | | - let (infcx, param_env) = |
244 | | - self.tcx.infer_ctxt().build_with_typing_env(self.typing_env); |
245 | | - |
246 | | - let ocx = ObligationCtxt::new(&infcx); |
247 | | - ocx.register_obligations(preds.iter().map(|pred: PolyExistentialPredicate<'_>| { |
248 | | - let pred = pred.with_self_ty(tcx, tp_ty); |
249 | | - // Lifetimes can only be 'static because of the bound on T |
250 | | - let pred = ty::fold_regions(tcx, pred, |r, _| { |
251 | | - if r == tcx.lifetimes.re_erased { tcx.lifetimes.re_static } else { r } |
252 | | - }); |
253 | | - Obligation::new(tcx, ObligationCause::dummy(), param_env, pred) |
254 | | - })); |
255 | | - let type_impls_trait = ocx.evaluate_obligations_error_on_ambiguity().is_empty(); |
256 | | - // Since `assumed_wf_tys=[]` the choice of LocalDefId is irrelevant, so using the "default" |
257 | | - let regions_are_valid = ocx.resolve_regions(CRATE_DEF_ID, param_env, []).is_empty(); |
258 | | - |
259 | | - if regions_are_valid && type_impls_trait { |
260 | | - let vtable_ptr = self.get_vtable_ptr(tp_ty, preds)?; |
261 | | - // Writing a non-null pointer into an `Option<NonNull>` will automatically make it `Some`. |
262 | | - self.write_pointer(vtable_ptr, dest)?; |
263 | | - } else { |
264 | | - // Write `None` |
265 | | - self.write_discriminant(FIRST_VARIANT, dest)?; |
266 | | - } |
267 | | - } |
268 | 227 | sym::variant_count => { |
269 | 228 | let tp_ty = instance.args.type_at(0); |
270 | 229 | let ty = match tp_ty.kind() { |
|
0 commit comments