@@ -176,7 +176,7 @@ impl<'tcx> ConstValue<'tcx> {
176
176
177
177
#[ derive( Clone , Copy , PartialEq , TyEncodable , TyDecodable , Hash , HashStable ) ]
178
178
#[ derive( TypeFoldable , TypeVisitable ) ]
179
- pub struct Constant < ' tcx > {
179
+ pub struct Const < ' tcx > {
180
180
pub span : Span ,
181
181
182
182
/// Optional user-given type: for something like
@@ -186,12 +186,12 @@ pub struct Constant<'tcx> {
186
186
/// Needed for NLL to impose user-given type constraints.
187
187
pub user_ty : Option < UserTypeAnnotationIndex > ,
188
188
189
- pub literal : ConstantKind < ' tcx > ,
189
+ pub literal : ConstKind < ' tcx > ,
190
190
}
191
191
192
192
#[ derive( Clone , Copy , PartialEq , Eq , TyEncodable , TyDecodable , Hash , HashStable , Debug ) ]
193
193
#[ derive( TypeFoldable , TypeVisitable ) ]
194
- pub enum ConstantKind < ' tcx > {
194
+ pub enum ConstKind < ' tcx > {
195
195
/// This constant came from the type system.
196
196
///
197
197
/// Any way of turning `ty::Const` into `ConstValue` should go through `valtree_to_const_val`;
@@ -212,7 +212,7 @@ pub enum ConstantKind<'tcx> {
212
212
Val ( ConstValue < ' tcx > , Ty < ' tcx > ) ,
213
213
}
214
214
215
- impl < ' tcx > Constant < ' tcx > {
215
+ impl < ' tcx > Const < ' tcx > {
216
216
pub fn check_static_ptr ( & self , tcx : TyCtxt < ' _ > ) -> Option < DefId > {
217
217
match self . literal . try_to_scalar ( ) {
218
218
Some ( Scalar :: Ptr ( ptr, _size) ) => match tcx. global_alloc ( ptr. provenance ) {
@@ -231,27 +231,27 @@ impl<'tcx> Constant<'tcx> {
231
231
}
232
232
}
233
233
234
- impl < ' tcx > ConstantKind < ' tcx > {
234
+ impl < ' tcx > ConstKind < ' tcx > {
235
235
#[ inline( always) ]
236
236
pub fn ty ( & self ) -> Ty < ' tcx > {
237
237
match self {
238
- ConstantKind :: Ty ( c) => c. ty ( ) ,
239
- ConstantKind :: Val ( _, ty) | ConstantKind :: Unevaluated ( _, ty) => * ty,
238
+ ConstKind :: Ty ( c) => c. ty ( ) ,
239
+ ConstKind :: Val ( _, ty) | ConstKind :: Unevaluated ( _, ty) => * ty,
240
240
}
241
241
}
242
242
243
243
#[ inline]
244
244
pub fn try_to_scalar ( self ) -> Option < Scalar > {
245
245
match self {
246
- ConstantKind :: Ty ( c) => match c. kind ( ) {
246
+ ConstKind :: Ty ( c) => match c. kind ( ) {
247
247
ty:: ConstKind :: Value ( valtree) => match valtree {
248
248
ty:: ValTree :: Leaf ( scalar_int) => Some ( Scalar :: Int ( scalar_int) ) ,
249
249
ty:: ValTree :: Branch ( _) => None ,
250
250
} ,
251
251
_ => None ,
252
252
} ,
253
- ConstantKind :: Val ( val, _) => val. try_to_scalar ( ) ,
254
- ConstantKind :: Unevaluated ( ..) => None ,
253
+ ConstKind :: Val ( val, _) => val. try_to_scalar ( ) ,
254
+ ConstKind :: Unevaluated ( ..) => None ,
255
255
}
256
256
}
257
257
@@ -278,17 +278,17 @@ impl<'tcx> ConstantKind<'tcx> {
278
278
span : Option < Span > ,
279
279
) -> Result < ConstValue < ' tcx > , ErrorHandled > {
280
280
match self {
281
- ConstantKind :: Ty ( c) => {
281
+ ConstKind :: Ty ( c) => {
282
282
// We want to consistently have a "clean" value for type system constants (i.e., no
283
283
// data hidden in the padding), so we always go through a valtree here.
284
284
let val = c. eval ( tcx, param_env, span) ?;
285
285
Ok ( tcx. valtree_to_const_val ( ( self . ty ( ) , val) ) )
286
286
}
287
- ConstantKind :: Unevaluated ( uneval, _) => {
287
+ ConstKind :: Unevaluated ( uneval, _) => {
288
288
// FIXME: We might want to have a `try_eval`-like function on `Unevaluated`
289
289
tcx. const_eval_resolve ( param_env, uneval, span)
290
290
}
291
- ConstantKind :: Val ( val, _) => Ok ( val) ,
291
+ ConstKind :: Val ( val, _) => Ok ( val) ,
292
292
}
293
293
}
294
294
@@ -407,7 +407,7 @@ impl<'tcx> ConstantKind<'tcx> {
407
407
Self :: Val ( val, ty)
408
408
}
409
409
410
- /// Literals are converted to `ConstantKindVal `, const generic parameters are eagerly
410
+ /// Literals are converted to `ConstKind::Val `, const generic parameters are eagerly
411
411
/// converted to a constant, everything else becomes `Unevaluated`.
412
412
#[ instrument( skip( tcx) , level = "debug" , ret) ]
413
413
pub fn from_anon_const (
@@ -543,13 +543,13 @@ impl<'tcx> UnevaluatedConst<'tcx> {
543
543
}
544
544
}
545
545
546
- impl < ' tcx > Debug for Constant < ' tcx > {
546
+ impl < ' tcx > Debug for Const < ' tcx > {
547
547
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
548
548
write ! ( fmt, "{self}" )
549
549
}
550
550
}
551
551
552
- impl < ' tcx > Display for Constant < ' tcx > {
552
+ impl < ' tcx > Display for Const < ' tcx > {
553
553
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
554
554
match self . ty ( ) . kind ( ) {
555
555
ty:: FnDef ( ..) => { }
@@ -559,13 +559,13 @@ impl<'tcx> Display for Constant<'tcx> {
559
559
}
560
560
}
561
561
562
- impl < ' tcx > Display for ConstantKind < ' tcx > {
562
+ impl < ' tcx > Display for ConstKind < ' tcx > {
563
563
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
564
564
match * self {
565
- ConstantKind :: Ty ( c) => pretty_print_const ( c, fmt, true ) ,
566
- ConstantKind :: Val ( val, ty) => pretty_print_const_value ( val, ty, fmt) ,
565
+ ConstKind :: Ty ( c) => pretty_print_const ( c, fmt, true ) ,
566
+ ConstKind :: Val ( val, ty) => pretty_print_const_value ( val, ty, fmt) ,
567
567
// FIXME(valtrees): Correctly print mir constants.
568
- ConstantKind :: Unevaluated ( ..) => {
568
+ ConstKind :: Unevaluated ( ..) => {
569
569
fmt. write_str ( "_" ) ?;
570
570
Ok ( ( ) )
571
571
}
0 commit comments