Try to fix problem
This commit is contained in:
parent
779eef2dae
commit
a00f2bcf5c
2 changed files with 17 additions and 4 deletions
|
@ -1084,11 +1084,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
span_mirbug!(
|
span_mirbug!(
|
||||||
self,
|
self,
|
||||||
user_annotation,
|
user_annotation,
|
||||||
"bad user type AscribeUserType({:?}, {:?} {:?}): {:?}",
|
"bad user type AscribeUserType({:?}, {:?} {:?}, type_of={:?}): {:?}",
|
||||||
inferred_ty,
|
inferred_ty,
|
||||||
def_id,
|
def_id,
|
||||||
user_substs,
|
user_substs,
|
||||||
terr
|
self.tcx().type_of(def_id),
|
||||||
|
terr,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||||
use rustc_infer::traits::TraitEngineExt as _;
|
use rustc_infer::traits::TraitEngineExt as _;
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
|
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
|
||||||
use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance};
|
use rustc_middle::ty::{
|
||||||
|
self, FnSig, Lift, PolyFnSig, PredicateKind, Ty, TyCtxt, TypeFoldable, Variance,
|
||||||
|
};
|
||||||
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate};
|
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
||||||
|
@ -85,7 +87,16 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prove_predicate(&mut self, predicate: Predicate<'tcx>) {
|
fn prove_predicate(&mut self, mut predicate: Predicate<'tcx>) {
|
||||||
|
if let PredicateKind::Trait(mut tr) = predicate.kind().skip_binder() {
|
||||||
|
if let hir::Constness::Const = tr.constness {
|
||||||
|
// FIXME check if we actually want to prove const predicates inside AscribeUserType
|
||||||
|
tr.constness = hir::Constness::NotConst;
|
||||||
|
predicate =
|
||||||
|
predicate.kind().rebind(PredicateKind::Trait(tr)).to_predicate(self.tcx());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.fulfill_cx.register_predicate_obligation(
|
self.fulfill_cx.register_predicate_obligation(
|
||||||
self.infcx,
|
self.infcx,
|
||||||
Obligation::new(ObligationCause::dummy(), self.param_env, predicate),
|
Obligation::new(ObligationCause::dummy(), self.param_env, predicate),
|
||||||
|
@ -126,6 +137,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||||
// outlives" error messages.
|
// outlives" error messages.
|
||||||
let instantiated_predicates =
|
let instantiated_predicates =
|
||||||
self.tcx().predicates_of(def_id).instantiate(self.tcx(), substs);
|
self.tcx().predicates_of(def_id).instantiate(self.tcx(), substs);
|
||||||
|
debug!(?instantiated_predicates.predicates);
|
||||||
for instantiated_predicate in instantiated_predicates.predicates {
|
for instantiated_predicate in instantiated_predicates.predicates {
|
||||||
let instantiated_predicate = self.normalize(instantiated_predicate);
|
let instantiated_predicate = self.normalize(instantiated_predicate);
|
||||||
self.prove_predicate(instantiated_predicate);
|
self.prove_predicate(instantiated_predicate);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue