make check less conservative and add explanation
This commit is contained in:
parent
54d4fc245a
commit
2931a9df2f
@ -649,7 +649,12 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||||||
if obligation.predicate.is_global() {
|
if obligation.predicate.is_global() {
|
||||||
// no type variables present, can use evaluation for better caching.
|
// no type variables present, can use evaluation for better caching.
|
||||||
// FIXME: consider caching errors too.
|
// FIXME: consider caching errors too.
|
||||||
if infcx.predicate_must_hold_considering_regions(obligation) {
|
//
|
||||||
|
// If the predicate is considered const, then we cannot use this because
|
||||||
|
// it will cause false negatives in the ui tests.
|
||||||
|
if !self.selcx.is_predicate_const(obligation.predicate)
|
||||||
|
&& infcx.predicate_must_hold_considering_regions(obligation)
|
||||||
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"selecting trait at depth {} evaluated to holds",
|
"selecting trait at depth {} evaluated to holds",
|
||||||
obligation.recursion_depth
|
obligation.recursion_depth
|
||||||
@ -703,7 +708,12 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||||||
if obligation.predicate.is_global() {
|
if obligation.predicate.is_global() {
|
||||||
// no type variables present, can use evaluation for better caching.
|
// no type variables present, can use evaluation for better caching.
|
||||||
// FIXME: consider caching errors too.
|
// FIXME: consider caching errors too.
|
||||||
if self.selcx.infcx().predicate_must_hold_considering_regions(obligation) {
|
//
|
||||||
|
// If the predicate is considered const, then we cannot use this because
|
||||||
|
// it will cause false negatives in the ui tests.
|
||||||
|
if !self.selcx.is_predicate_const(obligation.predicate)
|
||||||
|
&& self.selcx.infcx().predicate_must_hold_considering_regions(obligation)
|
||||||
|
{
|
||||||
return ProcessResult::Changed(vec![]);
|
return ProcessResult::Changed(vec![]);
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!("Does NOT hold: {:?}", obligation);
|
tracing::debug!("Does NOT hold: {:?}", obligation);
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
use rustc_hir as hir;
|
|
||||||
use rustc_middle::ty::PredicateKind;
|
|
||||||
|
|
||||||
use crate::infer::canonical::OriginalQueryValues;
|
use crate::infer::canonical::OriginalQueryValues;
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
@ -49,12 +46,6 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let PredicateKind::Trait(pred) = obligation.predicate.kind().skip_binder() {
|
|
||||||
if let hir::Constness::Const = pred.constness {
|
|
||||||
// do not evaluate to holds when we have a const predicate.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.evaluate_obligation_no_overflow(obligation).must_apply_considering_regions()
|
self.evaluate_obligation_no_overflow(obligation).must_apply_considering_regions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +316,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
self.infcx.tcx
|
self.infcx.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns `true` if the predicate is considered `const` to
|
||||||
|
/// this selection context.
|
||||||
|
pub fn is_predicate_const(&self, pred: ty::Predicate<'_>) -> bool {
|
||||||
|
match pred.kind().skip_binder() {
|
||||||
|
ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
|
constness: hir::Constness::Const,
|
||||||
|
..
|
||||||
|
}) if self.const_impls_required => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Selection
|
// Selection
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user