make check less conservative and add explanation
This commit is contained in:
parent
54d4fc245a
commit
2931a9df2f
@ -649,7 +649,12 @@ fn process_trait_obligation(
|
||||
if obligation.predicate.is_global() {
|
||||
// no type variables present, can use evaluation for better caching.
|
||||
// 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!(
|
||||
"selecting trait at depth {} evaluated to holds",
|
||||
obligation.recursion_depth
|
||||
@ -703,7 +708,12 @@ fn process_projection_obligation(
|
||||
if obligation.predicate.is_global() {
|
||||
// no type variables present, can use evaluation for better caching.
|
||||
// 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![]);
|
||||
} else {
|
||||
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::InferCtxt;
|
||||
use crate::traits::{
|
||||
@ -49,12 +46,6 @@ fn predicate_must_hold_considering_regions(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> 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()
|
||||
}
|
||||
|
||||
|
@ -316,6 +316,18 @@ pub fn tcx(&self) -> TyCtxt<'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
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user