@@ -1995,34 +1995,36 @@ crate enum Constant {
19951995 /// nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also
19961996 /// used to define explicit discriminant values for enum variants.
19971997 Anonymous { type_ : Type , body : BodyId } ,
1998- /// Inlined constant.
1999- Extern { type_ : Type , did : DefId } ,
1998+ /// A constant from a different crate .
1999+ Extern { type_ : Type , def_id : DefId } ,
20002000 /// const FOO: u32 = ...;
2001- Local { type_ : Type , did : DefId , body : BodyId } ,
2001+ Local { type_ : Type , def_id : DefId , body : BodyId } ,
20022002}
20032003
20042004impl Constant {
20052005 crate fn expr ( & self , tcx : TyCtxt < ' _ > ) -> String {
20062006 match self {
20072007 Self :: TyConst { expr, .. } => expr. clone ( ) ,
2008- Self :: Extern { did , .. } => print_inlined_const ( tcx, * did ) ,
2008+ Self :: Extern { def_id , .. } => print_inlined_const ( tcx, * def_id ) ,
20092009 Self :: Local { body, .. } | Self :: Anonymous { body, .. } => print_const_expr ( tcx, * body) ,
20102010 }
20112011 }
20122012
20132013 crate fn value ( & self , tcx : TyCtxt < ' _ > ) -> Option < String > {
20142014 match self {
20152015 Self :: TyConst { .. } | Self :: Anonymous { .. } => None ,
2016- Self :: Extern { did, .. } | Self :: Local { did, .. } => print_evaluated_const ( tcx, * did) ,
2016+ Self :: Extern { def_id, .. } | Self :: Local { def_id, .. } => {
2017+ print_evaluated_const ( tcx, * def_id)
2018+ }
20172019 }
20182020 }
20192021
20202022 crate fn is_literal ( & self , tcx : TyCtxt < ' _ > ) -> bool {
20212023 match self {
20222024 Self :: TyConst { .. } => false ,
2023- Self :: Extern { did , .. } => did
2024- . as_local ( )
2025- . map_or ( false , |did| is_literal_expr ( tcx , tcx . hir ( ) . local_def_id_to_hir_id ( did ) ) ) ,
2025+ Self :: Extern { def_id , .. } => def_id . as_local ( ) . map_or ( false , |def_id| {
2026+ is_literal_expr ( tcx , tcx . hir ( ) . local_def_id_to_hir_id ( def_id ) )
2027+ } ) ,
20262028 Self :: Local { body, .. } | Self :: Anonymous { body, .. } => {
20272029 is_literal_expr ( tcx, body. hir_id )
20282030 }
0 commit comments