@@ -140,12 +140,6 @@ impl<'tcx> Const<'tcx> {
140
140
}
141
141
}
142
142
143
- /// Interns the given value as a constant.
144
- #[ inline]
145
- pub fn from_value ( tcx : TyCtxt < ' tcx > , val : ty:: ValTree < ' tcx > , ty : Ty < ' tcx > ) -> Self {
146
- tcx. mk_const ( val, ty)
147
- }
148
-
149
143
/// Panics if self.kind != ty::ConstKind::Value
150
144
pub fn to_valtree ( self ) -> ty:: ValTree < ' tcx > {
151
145
match self . kind ( ) {
@@ -156,7 +150,7 @@ impl<'tcx> Const<'tcx> {
156
150
157
151
pub fn from_scalar_int ( tcx : TyCtxt < ' tcx > , i : ScalarInt , ty : Ty < ' tcx > ) -> Self {
158
152
let valtree = ty:: ValTree :: from_scalar_int ( i) ;
159
- Self :: from_value ( tcx, valtree, ty)
153
+ tcx. mk_const ( valtree, ty)
160
154
}
161
155
162
156
#[ inline]
@@ -172,8 +166,7 @@ impl<'tcx> Const<'tcx> {
172
166
#[ inline]
173
167
/// Creates an interned zst constant.
174
168
pub fn zero_sized ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> Self {
175
- let valtree = ty:: ValTree :: zst ( ) ;
176
- Self :: from_value ( tcx, valtree, ty)
169
+ tcx. mk_const ( ty:: ValTree :: zst ( ) , ty)
177
170
}
178
171
179
172
#[ inline]
@@ -220,7 +213,7 @@ impl<'tcx> Const<'tcx> {
220
213
pub fn eval ( self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Const < ' tcx > {
221
214
if let Some ( val) = self . kind ( ) . try_eval_for_typeck ( tcx, param_env) {
222
215
match val {
223
- Ok ( val) => Const :: from_value ( tcx, val, self . ty ( ) ) ,
216
+ Ok ( val) => tcx. mk_const ( val, self . ty ( ) ) ,
224
217
Err ( guar) => tcx. const_error_with_guaranteed ( self . ty ( ) , guar) ,
225
218
}
226
219
} else {
0 commit comments