Skip to content

Commit 638b612

Browse files
committed
remove ty::Const::from_inline_const
1 parent 7207b4d commit 638b612

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use crate::mir::interpret::LitToConstInput;
22
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};
74
use rustc_data_structures::intern::Interned;
85
use rustc_errors::ErrorGuaranteed;
96
use rustc_hir as hir;
@@ -151,46 +148,6 @@ impl<'tcx> Const<'tcx> {
151148
}
152149
}
153150

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-
194151
/// Interns the given value as a constant.
195152
#[inline]
196153
pub fn from_value(tcx: TyCtxt<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> Self {

0 commit comments

Comments
 (0)