|
1 | 1 | use crate::mir::interpret::LitToConstInput;
|
2 | 2 | use crate::mir::ConstantKind;
|
3 |
| -use crate::ty::{ |
4 |
| - self, InlineConstSubsts, InlineConstSubstsParts, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, |
5 |
| - TyCtxt, TypeVisitable, |
6 |
| -}; |
| 3 | +use crate::ty::{self, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, TyCtxt}; |
7 | 4 | use rustc_data_structures::intern::Interned;
|
8 | 5 | use rustc_errors::ErrorGuaranteed;
|
9 | 6 | use rustc_hir as hir;
|
@@ -151,46 +148,6 @@ impl<'tcx> Const<'tcx> {
|
151 | 148 | }
|
152 | 149 | }
|
153 | 150 |
|
154 |
| - pub fn from_inline_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self { |
155 |
| - debug!("Const::from_inline_const(def_id={:?})", def_id); |
156 |
| - |
157 |
| - let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); |
158 |
| - |
159 |
| - let body_id = match tcx.hir().get(hir_id) { |
160 |
| - hir::Node::AnonConst(ac) => ac.body, |
161 |
| - _ => span_bug!( |
162 |
| - tcx.def_span(def_id.to_def_id()), |
163 |
| - "from_inline_const can only process anonymous constants" |
164 |
| - ), |
165 |
| - }; |
166 |
| - |
167 |
| - let expr = &tcx.hir().body(body_id).value; |
168 |
| - |
169 |
| - let ty = tcx.typeck(def_id).node_type(hir_id); |
170 |
| - |
171 |
| - let ret = match Self::try_eval_lit_or_param(tcx, ty, expr) { |
172 |
| - Some(v) => v, |
173 |
| - None => { |
174 |
| - let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id()); |
175 |
| - let parent_substs = |
176 |
| - tcx.erase_regions(InternalSubsts::identity_for_item(tcx, typeck_root_def_id)); |
177 |
| - let substs = |
178 |
| - InlineConstSubsts::new(tcx, InlineConstSubstsParts { parent_substs, ty }) |
179 |
| - .substs; |
180 |
| - tcx.mk_const(ty::ConstS { |
181 |
| - kind: ty::ConstKind::Unevaluated(ty::Unevaluated { |
182 |
| - def: ty::WithOptConstParam::unknown(def_id).to_global(), |
183 |
| - substs, |
184 |
| - promoted: (), |
185 |
| - }), |
186 |
| - ty, |
187 |
| - }) |
188 |
| - } |
189 |
| - }; |
190 |
| - debug_assert!(!ret.has_free_regions()); |
191 |
| - ret |
192 |
| - } |
193 |
| - |
194 | 151 | /// Interns the given value as a constant.
|
195 | 152 | #[inline]
|
196 | 153 | pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Self {
|
|
0 commit comments