@@ -6,7 +6,9 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
6
6
use rustc_infer:: traits:: TraitEngineExt as _;
7
7
use rustc_middle:: ty:: query:: Providers ;
8
8
use rustc_middle:: ty:: subst:: { GenericArg , Subst , UserSelfTy , UserSubsts } ;
9
- use rustc_middle:: ty:: { self , FnSig , Lift , PolyFnSig , Ty , TyCtxt , TypeFoldable , Variance } ;
9
+ use rustc_middle:: ty:: {
10
+ self , FnSig , Lift , PolyFnSig , PredicateKind , Ty , TyCtxt , TypeFoldable , Variance ,
11
+ } ;
10
12
use rustc_middle:: ty:: { ParamEnv , ParamEnvAnd , Predicate , ToPredicate } ;
11
13
use rustc_span:: DUMMY_SP ;
12
14
use rustc_trait_selection:: infer:: InferCtxtBuilderExt ;
@@ -85,7 +87,16 @@ impl AscribeUserTypeCx<'me, 'tcx> {
85
87
Ok ( ( ) )
86
88
}
87
89
88
- fn prove_predicate ( & mut self , predicate : Predicate < ' tcx > ) {
90
+ fn prove_predicate ( & mut self , mut predicate : Predicate < ' tcx > ) {
91
+ if let PredicateKind :: Trait ( mut tr) = predicate. kind ( ) . skip_binder ( ) {
92
+ if let hir:: Constness :: Const = tr. constness {
93
+ // FIXME check if we actually want to prove const predicates inside AscribeUserType
94
+ tr. constness = hir:: Constness :: NotConst ;
95
+ predicate =
96
+ predicate. kind ( ) . rebind ( PredicateKind :: Trait ( tr) ) . to_predicate ( self . tcx ( ) ) ;
97
+ }
98
+ }
99
+
89
100
self . fulfill_cx . register_predicate_obligation (
90
101
self . infcx ,
91
102
Obligation :: new ( ObligationCause :: dummy ( ) , self . param_env , predicate) ,
@@ -126,6 +137,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
126
137
// outlives" error messages.
127
138
let instantiated_predicates =
128
139
self . tcx ( ) . predicates_of ( def_id) . instantiate ( self . tcx ( ) , substs) ;
140
+ debug ! ( ?instantiated_predicates. predicates) ;
129
141
for instantiated_predicate in instantiated_predicates. predicates {
130
142
let instantiated_predicate = self . normalize ( instantiated_predicate) ;
131
143
self . prove_predicate ( instantiated_predicate) ;
0 commit comments