File tree 3 files changed +20
-0
lines changed
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ pub mod transform;
35
35
pub mod util;
36
36
37
37
use rustc_middle:: ty:: query:: Providers ;
38
+ use rustc_middle:: ty:: ParamEnv ;
38
39
39
40
pub fn provide ( providers : & mut Providers ) {
40
41
const_eval:: provide ( providers) ;
@@ -49,6 +50,9 @@ pub fn provide(providers: &mut Providers) {
49
50
let ( param_env, raw) = param_env_and_value. into_parts ( ) ;
50
51
const_eval:: const_to_valtree ( tcx, param_env, raw)
51
52
} ;
53
+ providers. valtree_to_const_val = |tcx, ( ty, valtree) | {
54
+ const_eval:: valtree_to_const_value ( tcx, ParamEnv :: empty ( ) . and ( ty) , valtree)
55
+ } ;
52
56
providers. deref_const = |tcx, param_env_and_value| {
53
57
let ( param_env, value) = param_env_and_value. into_parts ( ) ;
54
58
const_eval:: deref_const ( tcx, param_env, value)
Original file line number Diff line number Diff line change @@ -936,6 +936,11 @@ rustc_queries! {
936
936
remap_env_constness
937
937
}
938
938
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
+
939
944
/// Destructure a constant ADT or array into its variant index and its
940
945
/// field values or return `None` if constant is invalid.
941
946
///
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>>) {
502
502
self . 0 . default_span ( tcx)
503
503
}
504
504
}
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