@@ -6,7 +6,9 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
66use rustc_infer:: traits:: TraitEngineExt as _;
77use rustc_middle:: ty:: query:: Providers ;
88use 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+ } ;
1012use rustc_middle:: ty:: { ParamEnv , ParamEnvAnd , Predicate , ToPredicate } ;
1113use rustc_span:: DUMMY_SP ;
1214use rustc_trait_selection:: infer:: InferCtxtBuilderExt ;
@@ -85,7 +87,16 @@ impl AscribeUserTypeCx<'me, 'tcx> {
8587 Ok ( ( ) )
8688 }
8789
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+
89100 self . fulfill_cx . register_predicate_obligation (
90101 self . infcx ,
91102 Obligation :: new ( ObligationCause :: dummy ( ) , self . param_env , predicate) ,
@@ -126,6 +137,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
126137 // outlives" error messages.
127138 let instantiated_predicates =
128139 self . tcx ( ) . predicates_of ( def_id) . instantiate ( self . tcx ( ) , substs) ;
140+ debug ! ( ?instantiated_predicates. predicates) ;
129141 for instantiated_predicate in instantiated_predicates. predicates {
130142 let instantiated_predicate = self . normalize ( instantiated_predicate) ;
131143 self . prove_predicate ( instantiated_predicate) ;
0 commit comments