|
3 | 3 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html |
4 | 4 |
|
5 | 5 | use crate::mir::interpret::{ |
6 | | - AllocRange, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, LitToConstInput, Scalar, |
| 6 | + AllocRange, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar, |
7 | 7 | }; |
8 | 8 | use crate::mir::visit::MirVisitable; |
9 | 9 | use crate::ty::codec::{TyDecoder, TyEncoder}; |
@@ -2461,51 +2461,6 @@ impl<'tcx> ConstantKind<'tcx> { |
2461 | 2461 | Self::Val(val, ty) |
2462 | 2462 | } |
2463 | 2463 |
|
2464 | | - #[instrument(skip(tcx), level = "debug", ret)] |
2465 | | - pub fn from_inline_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self { |
2466 | | - let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); |
2467 | | - let body_id = match tcx.hir().get(hir_id) { |
2468 | | - hir::Node::AnonConst(ac) => ac.body, |
2469 | | - _ => span_bug!( |
2470 | | - tcx.def_span(def_id.to_def_id()), |
2471 | | - "from_inline_const can only process anonymous constants" |
2472 | | - ), |
2473 | | - }; |
2474 | | - let expr = &tcx.hir().body(body_id).value; |
2475 | | - let ty = tcx.typeck(def_id).node_type(hir_id); |
2476 | | - |
2477 | | - let lit_input = match expr.kind { |
2478 | | - hir::ExprKind::Lit(ref lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }), |
2479 | | - hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => match expr.kind { |
2480 | | - hir::ExprKind::Lit(ref lit) => { |
2481 | | - Some(LitToConstInput { lit: &lit.node, ty, neg: true }) |
2482 | | - } |
2483 | | - _ => None, |
2484 | | - }, |
2485 | | - _ => None, |
2486 | | - }; |
2487 | | - if let Some(lit_input) = lit_input { |
2488 | | - // If an error occurred, ignore that it's a literal and leave reporting the error up to |
2489 | | - // mir. |
2490 | | - match tcx.at(expr.span).lit_to_mir_constant(lit_input) { |
2491 | | - Ok(c) => return c, |
2492 | | - Err(_) => {} |
2493 | | - } |
2494 | | - } |
2495 | | - |
2496 | | - let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id()); |
2497 | | - let parent_substs = |
2498 | | - tcx.erase_regions(InternalSubsts::identity_for_item(tcx, typeck_root_def_id)); |
2499 | | - let substs = |
2500 | | - ty::InlineConstSubsts::new(tcx, ty::InlineConstSubstsParts { parent_substs, ty }) |
2501 | | - .substs; |
2502 | | - |
2503 | | - let uneval = UnevaluatedConst { def: def_id.to_def_id(), substs, promoted: None }; |
2504 | | - debug_assert!(!uneval.has_free_regions()); |
2505 | | - |
2506 | | - Self::Unevaluated(uneval, ty) |
2507 | | - } |
2508 | | - |
2509 | 2464 | /// Literals are converted to `ConstantKindVal`, const generic parameters are eagerly |
2510 | 2465 | /// converted to a constant, everything else becomes `Unevaluated`. |
2511 | 2466 | #[instrument(skip(tcx), level = "debug", ret)] |
|
0 commit comments