This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ pub mod transform;
3535pub mod util;
3636
3737use rustc_middle:: ty:: query:: Providers ;
38+ use rustc_middle:: ty:: ParamEnv ;
3839
3940pub fn provide ( providers : & mut Providers ) {
4041 const_eval:: provide ( providers) ;
@@ -49,6 +50,9 @@ pub fn provide(providers: &mut Providers) {
4950 let ( param_env, raw) = param_env_and_value. into_parts ( ) ;
5051 const_eval:: const_to_valtree ( tcx, param_env, raw)
5152 } ;
53+ providers. valtree_to_const_val = |tcx, ( ty, valtree) | {
54+ const_eval:: valtree_to_const_value ( tcx, ParamEnv :: empty ( ) . and ( ty) , valtree)
55+ } ;
5256 providers. deref_const = |tcx, param_env_and_value| {
5357 let ( param_env, value) = param_env_and_value. into_parts ( ) ;
5458 const_eval:: deref_const ( tcx, param_env, value)
Original file line number Diff line number Diff line change @@ -936,6 +936,11 @@ rustc_queries! {
936936 remap_env_constness
937937 }
938938
939+ /// Converts a type level constant value into `ConstValue`
940+ query valtree_to_const_val( key: ( Ty <' tcx>, ty:: ValTree <' tcx>) ) -> ConstValue <' tcx> {
941+ desc { "convert type-level constant value to mir constant value" }
942+ }
943+
939944 /// Destructure a constant ADT or array into its variant index and its
940945 /// field values or return `None` if constant is invalid.
941946 ///
Original file line number Diff line number Diff line change @@ -502,3 +502,14 @@ impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
502502 self . 0 . default_span ( tcx)
503503 }
504504}
505+
506+ impl < ' tcx > Key for ( Ty < ' tcx > , ty:: ValTree < ' tcx > ) {
507+ #[ inline( always) ]
508+ fn query_crate_is_local ( & self ) -> bool {
509+ true
510+ }
511+
512+ fn default_span ( & self , _: TyCtxt < ' _ > ) -> Span {
513+ DUMMY_SP
514+ }
515+ }
You can’t perform that action at this time.
0 commit comments